summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Wilken2023-02-25 14:21:10 +0100
committerTimo Wilken2023-02-25 14:21:10 +0100
commit942f1d720cbdd24a36d7a94c9c802ee523380a69 (patch)
tree4603d275fa19ea3b11f9565ab5f63ce7428b4979
parent1fcc1b28bbdb2bdeb0300899baddd075c9f407a8 (diff)
Try importing various golang packages for Prometheusmonitoring
-rw-r--r--tw/packages/monitoring-imported.scm13
-rw-r--r--tw/packages/monitoring.scm368
2 files changed, 308 insertions, 73 deletions
diff --git a/tw/packages/monitoring-imported.scm b/tw/packages/monitoring-imported.scm
new file mode 100644
index 00000000..b37080b2
--- /dev/null
+++ b/tw/packages/monitoring-imported.scm
@@ -0,0 +1,13 @@
+(define-module (tw packages monitoring-imported)
+ #:use-module (gnu packages golang)
+ #:use-module ((gnu packages syncthing)
+ #:select (go-github-com-prometheus-common
+ go-github-com-prometheus-client-golang
+ go-github-com-prometheus-client-model
+ go-github-com-prometheus-procfs))
+ #:use-module (guix build-system go)
+ #:use-module (guix git-download)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix packages))
+
+;; guix import go -r github.com/prometheus-community/json_exporter >> tw/packages/monitoring-imported.scm
diff --git a/tw/packages/monitoring.scm b/tw/packages/monitoring.scm
index af7c3726..61722ab8 100644
--- a/tw/packages/monitoring.scm
+++ b/tw/packages/monitoring.scm
@@ -1,14 +1,17 @@
(define-module (tw packages monitoring)
#:use-module (gnu packages golang)
#:use-module ((gnu packages syncthing)
- #:select (go-github-com-prometheus-common
+ #:select (go-github-com-matttproud-golang-protobuf-extensions-pbutil
+ go-github-com-prometheus-common
go-github-com-prometheus-client-golang
- go-github-com-prometheus-client-model))
+ go-github-com-prometheus-client-model
+ go-github-com-prometheus-procfs))
#:use-module (guix build-system go)
#:use-module (guix git-download)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages))
+#!
(define-public go-github-com-go-logfmt-logfmt
(package
(name "go-github-com-go-logfmt-logfmt")
@@ -111,6 +114,79 @@ following this README on a Linux machine running systemd:
@url{https://github.com/coreos/go-systemd/tree/main/examples/activation/httpserver}")
(license license:asl2.0)))
+(define-public go-google-golang-org-protobuf-latest
+ (package
+ (inherit go-github-com-golang-protobuf-proto)
+ (name "go-google-golang-org-protobuf")
+ ;; github.com/golang/protobuf v1.5.2 requires google.golang.org/protobuf v1.26.0
+ (version "1.26.0")
+ (home-page "https://github.com/protocolbuffers/protobuf-go")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference (url home-page) (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256 (base32 "0xq6phaps6d0vcv13ga59gzj4306l0ki9kikhmb52h6pq0iwfqlz"))))
+ (arguments
+ '(#:import-path "google.golang.org/protobuf/..."
+ #:unpack-path "google.golang.org/protobuf"
+ #:phases (modify-phases %standard-phases
+ (replace 'install
+ (lambda* (#:key import-path outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ ;; We can't use import-path as-is here;
+ ;; we need to strip the trailing "/...".
+ (fixed-import-path
+ (if (string-suffix? "/..." import-path)
+ (substring import-path 0
+ (- (string-length import-path) 4))
+ import-path))
+ (source (string-append (getenv "GOPATH")
+ "/src/" fixed-import-path))
+ (dest (string-append out "/src/" fixed-import-path)))
+ (mkdir-p dest)
+ (copy-recursively source dest #:keep-mtime? #t)))))))
+ (native-inputs ; unit tests
+ (list go-github-com-google-go-cmp-cmp))))
+
+(define-public go-github-com-golang-protobuf-latest
+ (package
+ (inherit go-github-com-golang-protobuf-proto)
+ (name "go-github-com-golang-protobuf")
+ (version "1.5.2")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url (package-home-page go-github-com-golang-protobuf-proto))
+ (commit (string-append "v" version))))
+ (file-name (git-file-name
+ (package-name go-github-com-golang-protobuf-proto) version))
+ (sha256 (base32 "1mh5fyim42dn821nsd3afnmgscrzzhn3h8rag635d2jnr23r1zhk"))))
+ (arguments
+ '(#:import-path "github.com/golang/protobuf/..."
+ #:unpack-path "github.com/golang/protobuf"
+ #:phases (modify-phases %standard-phases
+ (replace 'install
+ (lambda* (#:key import-path outputs #:allow-other-keys)
+ (let* ((out (assoc-ref outputs "out"))
+ ;; We can't use import-path as-is here;
+ ;; we need to strip the trailing "/...".
+ (fixed-import-path
+ (if (string-suffix? "/..." import-path)
+ (substring import-path 0
+ (- (string-length import-path) 4))
+ import-path))
+ (source (string-append (getenv "GOPATH")
+ "/src/" fixed-import-path))
+ (dest (string-append out "/src/" fixed-import-path)))
+ (mkdir-p dest)
+ (copy-recursively source dest #:keep-mtime? #t)))))))
+ (propagated-inputs (list go-google-golang-org-protobuf-latest))
+ (native-inputs (list go-github-com-google-go-cmp-cmp)))) ; unit tests
+
+;; -----------------------------------------------------------------------------
+
;; For some reason, the google.golang.org/protobuf package does not install
;; anything, so we have to install its subpackages individually.
(define (protobuf-subpackage subpath)
@@ -147,22 +223,21 @@ buffer developer guide} for more information about protocol buffers
themselves.")
(license license:bsd-3)))
-;; TODO: github.com/golang/protobuf/ptypes/timestamp required by github.com/prometheus/exporter-toolkit/web
-(define-public go-github-com-golang-protobuf-proto-latest
+(define-public go-github-com-golang-protobuf-ptypes-timestamppb-latest
(package
(inherit go-github-com-golang-protobuf-proto)
+ (name "go-github-com-golang-protobuf-ptypes-timestamppb")
(version "1.5.2")
(source
(origin
(method git-fetch)
(uri (git-reference
- (url (package-home-page
- go-github-com-golang-protobuf-proto))
+ (url (package-home-page go-github-com-golang-protobuf-proto))
(commit (string-append "v" version))))
(file-name (git-file-name
(package-name go-github-com-golang-protobuf-proto) version))
(sha256 (base32 "1mh5fyim42dn821nsd3afnmgscrzzhn3h8rag635d2jnr23r1zhk"))))
- (arguments '(#:import-path "github.com/golang/protobuf/proto"
+ (arguments '(#:import-path "github.com/golang/protobuf/ptypes/timestamp"
#:unpack-path "github.com/golang/protobuf"))
(propagated-inputs
(map protobuf-subpackage
@@ -186,19 +261,48 @@ themselves.")
"internal/set"
"internal/strs"
"internal/version"
- "reflect/protodesc"
+ "proto"
"reflect/protoreflect"
"reflect/protoregistry"
"runtime/protoiface"
"runtime/protoimpl"
- "types/descriptorpb"
- "proto")))
- (native-inputs
- (cons* go-github-com-google-go-cmp-cmp
+ "types/known/timestamppb")))
+ (native-inputs ; unit tests
+ (list go-github-com-google-go-cmp-cmp
+ (protobuf-subpackage "testing/protopack")
+ (protobuf-subpackage "types/known/anypb")))))
+
+(define-public go-github-com-golang-protobuf-proto-latest
+ (package
+ (inherit go-github-com-golang-protobuf-ptypes-timestamppb-latest)
+ (name "go-github-com-golang-protobuf-proto")
+ (arguments '(#:import-path "github.com/golang/protobuf/proto"
+ #:unpack-path "github.com/golang/protobuf"))
+ (propagated-inputs
+ ;; Depend on inherited package as we need it.
+ ;; Its `propagated-inputs' come along with it!
+ (cons* go-github-com-golang-protobuf-ptypes-timestamppb-latest
(map protobuf-subpackage
- '("testing/protopack"
- "types/known/anypb"
- "types/known/timestamppb"))))))
+ '("reflect/protodesc" "types/descriptorpb"))))))
+
+;; -----------------------------------------------------------------------------
+
+(define-public go-github-com-matttproud-golang-protobuf-extensions-pbutil-latest
+ (package
+ (inherit go-github-com-matttproud-golang-protobuf-extensions-pbutil)
+ (version "1.0.4")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/matttproud/golang_protobuf_extensions")
+ (commit (string-append "v" version))))
+ (file-name
+ (git-file-name
+ (package-name go-github-com-matttproud-golang-protobuf-extensions-pbutil)
+ version))
+ (sha256 (base32 "1xqsf9vpcrd4hp95rl6kgmjvkv1df4aicfw4l5vfcxcwxknfx2xs"))))
+ (propagated-inputs (list go-github-com-golang-protobuf-latest))))
(define-public go-github-com-prometheus-client-model-latest
(package
@@ -216,7 +320,60 @@ themselves.")
(propagated-inputs
(modify-inputs (package-propagated-inputs go-github-com-prometheus-client-model)
(replace "go-github-com-golang-protobuf-proto"
- go-github-com-golang-protobuf-proto-latest)))))
+ go-github-com-golang-protobuf-latest)))))
+
+(define-public go-golang-org-x-sys-latest
+ (package
+ (inherit go-golang-org-x-sys)
+ (version "0.4.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://go.googlesource.com/sys")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name (package-name go-golang-org-x-sys) version))
+ (sha256 (base32 "0fr2d6fnpbqx6n89sg9lsinqkdaw49y068kqj2g0cxlhbh69hzii"))))))
+
+(define-public go-golang-org-x-crypto-latest
+ (package
+ (inherit go-golang-org-x-crypto)
+ (version "0.5.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://go.googlesource.com/crypto")
+ (commit (string-append "v" version))))
+ (file-name (string-append "go.googlesource.com-crypto-"
+ version "-checkout"))
+ (sha256 (base32 "0cpzkxx7n3xyrxg4qgkn2y5hbj0mdm8bp7ld0npr6yj4r2bbg0j0"))))
+ (propagated-inputs
+ (modify-inputs (package-propagated-inputs go-golang-org-x-crypto)
+ (replace "go-golang-org-x-sys"
+ go-golang-org-x-sys-latest)))))
+
+(define-public go-golang-org-x-net-latest
+ (package
+ (inherit go-golang-org-x-net)
+ (version "0.5.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://go.googlesource.com/net")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name (package-name go-golang-org-x-net) version))
+ (sha256 (base32 "1fidlcn3vcz42v2lc0rpmqh3bz08bcklj6jvnmz2vvgc481ci5hy"))))))
+
+(define-public go-golang-org-x-oauth2/latest-x-net
+ (package
+ (inherit go-golang-org-x-oauth2)
+ (propagated-inputs
+ (modify-inputs (package-propagated-inputs
+ go-golang-org-x-oauth2)
+ (replace "go-golang-org-x-net"
+ go-golang-org-x-net-latest)))))
(define-public go-github-com-prometheus-common-latest
(package
@@ -235,9 +392,66 @@ themselves.")
(modify-inputs (package-propagated-inputs go-github-com-prometheus-common)
(replace "go-github-com-prometheus-client-model"
go-github-com-prometheus-client-model-latest)
- (append go-golang-org-x-oauth2)
+ (replace "go-github-com-golang-protobuf-proto"
+ go-github-com-golang-protobuf-latest)
+ (replace "go-github-com-matttproud-golang-protobuf-extensions-pbutil"
+ go-github-com-matttproud-golang-protobuf-extensions-pbutil-latest)
+ (replace "go-golang-org-x-net"
+ go-golang-org-x-net-latest)
+ (append go-golang-org-x-oauth2/latest-x-net)
(append go-golang-org-x-text)))))
+(define-public go-github-com-prometheus-client-golang-latest
+ (package
+ (inherit go-github-com-prometheus-client-golang)
+ (propagated-inputs
+ (modify-inputs (package-propagated-inputs
+ go-github-com-prometheus-client-golang)
+ (replace "go-github-com-golang-protobuf-proto"
+ go-github-com-golang-protobuf-latest)
+ (replace "go-github-com-prometheus-common"
+ go-github-com-prometheus-common-latest)
+ (replace "go-github-com-prometheus-client-model"
+ go-github-com-prometheus-client-model-latest)))))
+
+(define-public go-github-com-mwitkow-go-conntrack
+ (let ((commit "2f068394615f73e460c2f3d2c158b0ad9321cadb") ; HEAD as of 2023-01-19
+ (revision "0"))
+ (package
+ (name "go-github-com-mwitkow-go-conntrack")
+ (version (git-version "0.0.0" revision commit))
+ (home-page "https://github.com/mwitkow/go-conntrack")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference (url home-page) (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256 (base32 "0ymjmy12ks7smgwmrwsa5kf07d9w5kpk1dn650azlzr61b561aw7"))))
+ (build-system go-build-system)
+ (arguments '(#:import-path "github.com/mwitkow/go-conntrack"))
+ (propagated-inputs (list go-github-com-jpillora-backoff
+ go-golang-org-x-net-latest ; go-golang-org-x-net
+ go-github-com-prometheus-client-golang-latest))
+ (native-inputs (list go-github-com-stretchr-testify)) ; for unit tests
+ (synopsis "Go middleware for net.Conn tracking (Prometheus/trace)")
+ (description "Prometheus monitoring and @code{x/net/trace} tracing
+wrappers for @code{net.Conn}, both inbound (@code{net.Listener}) and outbound
+(@code{net.Dialer}).")
+ (license license:asl2.0))))
+
+(define-public go-golang-org-x-sync-latest
+ (package
+ (inherit go-golang-org-x-sync)
+ (version "0.1.0")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://go.googlesource.com/sync")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name (package-name go-golang-org-x-sync) version))
+ (sha256 (base32 "07qrhni6f5hh5p95k1yk6s4wsj341q663irvx6rllrxfsymj6a0z"))))))
+
(define-public go-github-com-prometheus-exporter-toolkit-web
(package
(name "go-github-com-prometheus-exporter-toolkit-web")
@@ -253,10 +467,11 @@ themselves.")
(sha256 (base32 "07qib1prcrzdl2p1w5icq5mvw796q2aadhps3m7rj72mn08wv97f"))))
(build-system go-build-system)
(arguments '(#:import-path "github.com/prometheus/exporter-toolkit/web"
- #:unpack-path "github.com/prometheus/exporter-toolkit"))
+ #:unpack-path "github.com/prometheus/exporter-toolkit"
+ #:tests? #f)) ; unit tests fail when trying to connect to localhost apparently randomly
(propagated-inputs (list go-github-com-go-kit-log
- go-golang-org-x-crypto
- go-golang-org-x-sync
+ go-golang-org-x-crypto-latest
+ go-golang-org-x-sync-latest
go-gopkg-in-yaml-v2
go-github-com-coreos-go-systemd-v22-activation
go-github-com-mwitkow-go-conntrack
@@ -277,34 +492,34 @@ repository you are looking for.
@emph{This repository is currently WIP and experimental.}")
(license license:asl2.0)))
-(define-public go-github-com-mwitkow-go-conntrack
- (let ((commit "2f068394615f73e460c2f3d2c158b0ad9321cadb")
- (revision "0"))
- (package
- (name "go-github-com-mwitkow-go-conntrack")
- (version (git-version "0.0.0" revision commit))
- (home-page "https://github.com/mwitkow/go-conntrack")
- (source
- (origin
- (method git-fetch)
- (uri (git-reference (url home-page) (commit commit)))
- (file-name (git-file-name name version))
- (sha256 (base32 "0ymjmy12ks7smgwmrwsa5kf07d9w5kpk1dn650azlzr61b561aw7"))))
- (build-system go-build-system)
- (arguments '(#:import-path "github.com/mwitkow/go-conntrack"))
- (propagated-inputs (list go-github-com-jpillora-backoff
- go-golang-org-x-net
- go-github-com-prometheus-client-golang))
- (native-inputs (list go-github-com-stretchr-testify)) ; for unit tests
- (synopsis "Go middleware for net.Conn tracking (Prometheus/trace)")
- (description "Prometheus monitoring and @code{x/net/trace} tracing
-wrappers for @code{net.Conn}, both inbound (@code{net.Listener}) and outbound
-(@code{net.Dialer}).")
- (license license:asl2.0))))
-
(when (string>=? (package-version go) "1.18.0")
(warn "go-k8s-io-client-go-util-jsonpath can be updated to at least 0.26.0 now."))
+;; k8s.io/client-go/third_party/forked/golang/template
+
+(define-public go-k8s-io-client-go
+ (package
+ (name "go-k8s-io-client-go")
+ ;; Nothing significant changed in jsonpath between 0.23.0 and 0.26.0, but
+ ;; versions >0.23.0 require Go >=1.18 while Guix' default Go is 1.17.
+ ;; With k8s.io/client-go/util/jsonpath >0.23.0, same build error as:
+ ;; https://github.com/pelletier/go-toml/issues/812#issuecomment-1228430719
+ (version "0.23.0")
+ (home-page "https://github.com/kubernetes/client-go")
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference (url home-page) (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256 (base32 "0m33cvvz520ki0dh7ki9245si25g26wq2b77bw9jz7dcdjq1vqi8"))))
+ (build-system go-build-system)
+ (arguments '(#:import-path "k8s.io/client-go"
+ #:unpack-path "k8s.io/client-go"))
+ (synopsis "Go client for Kubernetes, which provides useful modules")
+ (description "Go clients for talking to a kubernetes cluster. Includes
+the @code{util/jsonpath} module.")
+ (license license:asl2.0)))
+
(define-public go-k8s-io-client-go-util-jsonpath
(package
(name "go-k8s-io-client-go-util-jsonpath")
@@ -326,6 +541,8 @@ wrappers for @code{net.Conn}, both inbound (@code{net.Listener}) and outbound
(build-system go-build-system)
(arguments '(#:import-path "k8s.io/client-go/util/jsonpath"
#:unpack-path "k8s.io/client-go"))
+ ;; (propagated-inputs
+ ;; (list go-k8s-io-client-go-third-party-forked-golang-template))
(synopsis "JSONPath module from Go client for Kubernetes")
(description "The @code{util/jsonpath} module taken from the Kubernetes Go
client.")
@@ -351,35 +568,40 @@ client.")
(file-name (git-file-name name version))
(sha256 (base32 "04nf3kgk5sjfj2zgc33alkpjmwkzzk93gnh3ap10r4ms67c2wxyz"))))
(build-system go-build-system)
- (arguments '(#:import-path "github.com/prometheus-community/json_exporter/cmd/main"
- #:unpack-path "github.com/prometheus-community/json_exporter"
+ (arguments '(#:import-path "github.com/prometheus-community/json_exporter"
#:install-source? #f))
- (inputs (list go-github-com-masterminds-sprig
- go-github-com-masterminds-goutils
- go-github-com-masterminds-semver
- go-github-com-go-logfmt-logfmt
- go-github-com-go-kit-log
- go-github-com-go-kit-kit-log
- go-github-com-google-uuid
- go-github-com-huandu-xstrings
- go-github-com-imdario-mergo
- go-github-com-mitchellh-copystructure
- go-github-com-mitchellh-reflectwalk
- go-github-com-mwitkow-go-conntrack
- go-github-com-pkg-errors
- go-github-com-spf13-cast
- go-golang-org-x-crypto
- go-gopkg-in-yaml-v2
- go-gopkg-in-alecthomas-kingpin
- go-k8s-io-client-go-util-jsonpath
- go-github-com-prometheus-client-golang
- go-github-com-prometheus-exporter-toolkit-web))
+ (native-inputs
+ (list go-github-com-masterminds-sprig
+ go-github-com-go-kit-log
+ go-gopkg-in-yaml-v2
+ go-gopkg-in-alecthomas-kingpin
+ go-k8s-io-client-go;-util-jsonpath
+ go-github-com-prometheus-client-golang-latest
+ go-github-com-prometheus-exporter-toolkit-web
+ ;; Indirect imports
+ go-github-com-alecthomas-template
+ go-github-com-alecthomas-units
+ go-github-com-masterminds-goutils
+ go-github-com-masterminds-semver
+ go-github-com-go-logfmt-logfmt
+ go-github-com-go-kit-kit-log
+ go-github-com-google-uuid
+ go-github-com-huandu-xstrings
+ go-github-com-imdario-mergo
+ go-github-com-mitchellh-copystructure
+ go-github-com-mitchellh-reflectwalk
+ go-github-com-mwitkow-go-conntrack
+ go-github-com-pkg-errors
+ go-github-com-spf13-cast
+ go-golang-org-x-crypto-latest))
(synopsis "Prometheus exporter which scrapes remote JSON by JSONPath")
- (description "A Prometheus exporter which scrapes remote JSON by
-JSONPath. For checking the JSONPath configuration supported by this exporter
-please head over @url{https://kubernetes.io/docs/reference/kubectl/jsonpath/, here}.
+ (description "A Prometheus exporter which scrapes remote JSON by JSONPath.
+For checking the JSONPath configuration supported by this exporter please head
+over @url{https://kubernetes.io/docs/reference/kubectl/jsonpath/, here}.
-Check out the @url{https://github.com/prometheus-community/json_exporter/blob/master/examples, examples}
-directory for sample exporter configuration, Prometheus configuration and
-expected data format.")
+Check out the
+@url{https://github.com/prometheus-community/json_exporter/blob/master/examples,
+examples} directory for sample exporter configuration, Prometheus
+configuration and expected data format.")
(license license:asl2.0)))
+!#