aboutsummaryrefslogtreecommitdiff
path: root/tw/packages/monitoring.scm
blob: 032b01f06c39e533372737684f019339e39692ae (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
(define-module (tw packages monitoring)
  #:use-module (gnu packages golang)
  #:use-module (gnu packages golang-build)
  #:use-module (gnu packages golang-check)
  #:use-module (gnu packages golang-web)
  #:use-module (gnu packages golang-xyz)
  #:use-module (gnu packages prometheus)
  #: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")
    (version "0.5.1")
    (home-page "https://github.com/go-logfmt/logfmt")
    (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 "01fs4x2aqw2qcsz18s4nfvyqv3rcwz5xmgpk3bic6nzgyzsjd7dp"))))
    (build-system go-build-system)
    (arguments '(#:import-path "github.com/go-logfmt/logfmt"))
    (synopsis "Marshals and unmarshals logfmt messages.")
    (description "Package logfmt implements utilities to marshal and unmarshal
data in the @url{https://brandur.org/logfmt, logfmt format}.  It provides an
API similar to @url{https://pkg.go.dev/encoding/json, @code{encoding/json}}
and @url{https://pkg.go.dev/encoding/xml, @code{encoding/xml}}.")
    (license license:expat)))

(define-public go-github-com-go-kit-log
  (package
    (name "go-github-com-go-kit-log")
    (version "0.2.1")
    (home-page "https://github.com/go-kit/log")
    (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 "1xjv2g1cd1iaghhm1c1zw0lcz89a9zq5xradyjipvrbqxbxckqm6"))))
    (build-system go-build-system)
    (arguments '(#:import-path "github.com/go-kit/log"))
    (propagated-inputs (list go-github-com-go-logfmt-logfmt))
    (synopsis "A minimal and extensible structured logger in Go")
    (description "@code{package log} provides a minimal interface for
structured logging in services.  It may be wrapped to encode conventions,
enforce type-safety, provide leveled logging, and so on.  It can be used for
both typical application log events, and log-structured data streams.")
    (license license:expat)))

(define-public go-github-com-go-kit-kit-log
  (package
    (name "go-github-com-go-kit-kit-log")
    (version "0.12.0")
    (home-page (string-append "https://github.com/go-kit/kit/tree/v" version "/log"))
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/go-kit/kit")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256 (base32 "15cm24sjyvwxpprfha2k0s3c1hhpg5y2kljnw04hayfyazqc79wl"))))
    (build-system go-build-system)
    (arguments '(#:import-path "github.com/go-kit/kit/log"
                 #:unpack-path "github.com/go-kit/kit"))
    (propagated-inputs (list go-github-com-go-kit-log
                             go-github-com-go-logfmt-logfmt))
    (synopsis "A minimal and extensible structured logger in Go")
    (description "@emph{Deprecation notice:} The core Go kit log packages
(@code{log}, @code{log/level}, @code{log/term}, and @code{log/syslog}) have
been moved to their own repository at @url{https://github.com/go-kit/log}.
The corresponding packages in this directory remain for backwards
compatibility.  Their types alias the types and their functions call the
functions provided by the new repository.  Using either import path should be
equivalent.  Prefer the new import path when practical.

@code{package log} provides a minimal interface for
structured logging in services.  It may be wrapped to encode conventions,
enforce type-safety, provide leveled logging, and so on.  It can be used for
both typical application log events, and log-structured data streams.")
    (license license:expat)))

(define-public go-github-com-coreos-go-systemd-v22-activation
  (package
    (name "go-github-com-coreos-go-systemd-v22-activation")
    (version "22.5.0")
    (home-page (string-append "https://github.com/coreos/go-systemd/tree/v"
                              version "/activation"))
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/coreos/go-systemd")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256 (base32 "1vhb4cw8nw9nx8mprx829xv8w4jnwhc2lcyjljzlfafsn8nx5nyf"))))
    (build-system go-build-system)
    (arguments '(#:import-path "github.com/coreos/go-systemd/v22/activation"
                 #:unpack-path "github.com/coreos/go-systemd/v22"))
    (synopsis "Go bindings to systemd socket activation")
    (description "Go bindings to systemd.  Of the several packages, only the
@code{activation} package is supplied here.  It is used for writing and using
systemd socket activation from Go.

An example HTTP server using socket activation can be quickly set up by
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)))

;; 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)
  (package
    (name (string-append
           "go-google-golang-org-protobuf-"
           (string-map (lambda (ch)
                         (if (char=? ch #\/) #\- ch))
                       subpath)))
    ;; 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"))))
    (build-system go-build-system)
    (arguments `(#:import-path ,(string-append "google.golang.org/protobuf/" subpath)
                 #:unpack-path "google.golang.org/protobuf"))
    (native-inputs (list go-github-com-google-go-cmp))   ; for unit tests
    (synopsis "Go support for Google's protocol buffers")
    (description "This project hosts the Go implementation for
@url{https://developers.google.com/protocol-buffers, protocol buffers}, which
is a language-neutral, platform-neutral, extensible mechanism for serializing
structured data.  The protocol buffer language is a language for specifying
the schema for structured data.  This schema is compiled into language
specific bindings.  This project provides both a tool to generate Go code for
the protocol buffer language, and also the runtime implementation to handle
serialization of messages in Go.  See the
@url{https://developers.google.com/protocol-buffers/docs/overview, protocol
buffer developer guide} for more information about protocol buffers
themselves.")
    (license license:bsd-3)))

(define-public go-github-com-golang-protobuf-latest
  (package
    (inherit 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))
             (commit (string-append "v" version))))
       (file-name (git-file-name
                   (package-name go-github-com-golang-protobuf) version))
       (sha256 (base32 "1mh5fyim42dn821nsd3afnmgscrzzhn3h8rag635d2jnr23r1zhk"))))
    (arguments '(#:import-path "github.com/golang/protobuf/proto"
                 #:unpack-path "github.com/golang/protobuf"))
    (propagated-inputs
     (cons*
      (map protobuf-subpackage
           '("encoding/prototext"
             "encoding/protowire"
             "internal/descfmt"
             "internal/descopts"
             "internal/detrand"
             "internal/encoding/defval"
             "internal/encoding/messageset"
             "internal/encoding/tag"
             "internal/encoding/text"
             "internal/errors"
             "internal/filedesc"
             "internal/filetype"
             "internal/flags"
             "internal/genid"
             "internal/impl"
             "internal/order"
             "internal/pragma"
             "internal/set"
             "internal/strs"
             "internal/version"
             "reflect/protodesc"
             "reflect/protoreflect"
             "reflect/protoregistry"
             "runtime/protoiface"
             "runtime/protoimpl"
             "types/descriptorpb"
             "proto"))))
    (native-inputs
     (cons* go-github-com-google-go-cmp
            (map protobuf-subpackage
                 '("testing/protopack"
                   "types/known/anypb"
                   "types/known/timestamppb"))))))

;; Apparently deprecated and removed from google.golang.org/protobuf, but
;; still required by github.com/prometheus/exporter-toolkit/web.
(define-public go-github-com-golang-protobuf-ptypes-timestamp
  (package
    (inherit go-github-com-golang-protobuf-latest)
    (name "go-github-com-golang-protobuf-ptypes-timestamp")
    (arguments '(#:import-path "github.com/golang/protobuf/ptypes/timestamp"
                 #:unpack-path "github.com/golang/protobuf"))
    (propagated-inputs
     (map protobuf-subpackage
          '("encoding/prototext"
            "encoding/protowire"
            "internal/descfmt"
            "internal/descopts"
            "internal/detrand"
            "internal/encoding/defval"
            "internal/encoding/messageset"
            "internal/encoding/tag"
            "internal/encoding/text"
            "internal/errors"
            "internal/filedesc"
            "internal/filetype"
            "internal/flags"
            "internal/genid"
            "internal/impl"
            "internal/order"
            "internal/pragma"
            "internal/set"
            "internal/strs"
            "internal/version"
            "reflect/protoreflect"
            "reflect/protoregistry"
            "runtime/protoiface"
            "runtime/protoimpl"
            "types/known/timestamppb"
            "proto")))
    (native-inputs (list))))

(define-public go-github-com-prometheus-client-model-latest
  (package
    (inherit go-github-com-prometheus-client-model)
    (version "0.3.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url (package-home-page go-github-com-prometheus-client-model))
             (commit (string-append "v" version))))
       (file-name (git-file-name
                   (package-name go-github-com-prometheus-client-model) version))
       (sha256 (base32 "199qx1hz28gjva9sx0zhfs7hq43fzz687bnp3daax87cjy4adzxw"))))
    (propagated-inputs
     (modify-inputs (package-propagated-inputs go-github-com-prometheus-client-model)
       (replace "go-github-com-golang-protobuf"
         go-github-com-golang-protobuf-latest)))))

(define-public go-github-com-prometheus-common-latest
  (package
    (inherit go-github-com-prometheus-common)
    (version "0.39.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url (package-home-page go-github-com-prometheus-common))
             (commit (string-append "v" version))))
       (file-name (git-file-name
                   (package-name go-github-com-prometheus-common) version))
       (sha256 (base32 "1i3kx3b3v5y0xbyc0n434x3qshk0fl738110lbfslxhvsidhpq1l"))))
    (propagated-inputs
     (modify-inputs (package-propagated-inputs go-github-com-prometheus-common)
       (replace "go-github-com-prometheus-client-model"
         go-github-com-prometheus-client-model-latest)
       ;; Really, go-github-com-mwitkow-go-conntrack should go here, but that
       ;; causes a symlink duplication or similar ("In procedure copy-file:
       ;; Permission denied").
       (append go-golang-org-x-oauth2)
       (append go-golang-org-x-text)))))

;; TODO: Build errors; possibly from depending on go-github-com-golang-protobuf-latest + go-github-com-golang-protobuf-ptypes-timestamp?
;; # github.com/golang/protobuf/proto
;; src/github.com/golang/protobuf/proto/decode.go:57:6: DecodeVarint redeclared in this block
;; /tmp/guix-build-go-github-com-prometheus-exporter-toolkit-web-0.8.2.drv-0/src/github.com/golang/protobuf/proto/buffer.go:39:38: previous declaration
;; src/github.com/golang/protobuf/proto/deprecated.go:24:2: ErrInternalBadWireType redeclared in this block
;; /tmp/guix-build-go-github-com-prometheus-exporter-toolkit-web-0.8.2.drv-0/src/github.com/golang/protobuf/proto/decode.go:49:5: previous declaration
;; src/github.com/golang/protobuf/proto/encode.go:53:2: ErrNil redeclared in this block
;; /tmp/guix-build-go-github-com-prometheus-exporter-toolkit-web-0.8.2.drv-0/src/github.com/golang/protobuf/proto/deprecated.go:18:2: previous declaration
;; src/github.com/golang/protobuf/proto/encode.go:57:2: ErrTooLarge redeclared in this block
;; /tmp/guix-build-go-github-com-prometheus-exporter-toolkit-web-0.8.2.drv-0/src/github.com/golang/protobuf/proto/deprecated.go:21:2: previous declaration
;; src/github.com/golang/protobuf/proto/encode.go:72:6: EncodeVarint redeclared in this block
;; /tmp/guix-build-go-github-com-prometheus-exporter-toolkit-web-0.8.2.drv-0/src/github.com/golang/protobuf/proto/buffer.go:26:31: previous declaration
;; src/github.com/golang/protobuf/proto/encode.go:98:6: SizeVarint redeclared in this block
;; /tmp/guix-build-go-github-com-prometheus-exporter-toolkit-web-0.8.2.drv-0/src/github.com/golang/protobuf/proto/buffer.go:32:27: previous declaration
;; src/github.com/golang/protobuf/proto/lib.go:349:6: Buffer redeclared in this block
;; /tmp/guix-build-go-github-com-prometheus-exporter-toolkit-web-0.8.2.drv-0/src/github.com/golang/protobuf/proto/buffer.go:49:6: previous declaration
;; src/github.com/golang/protobuf/proto/lib.go:358:6: NewBuffer redeclared in this block
;; /tmp/guix-build-go-github-com-prometheus-exporter-toolkit-web-0.8.2.drv-0/src/github.com/golang/protobuf/proto/buffer.go:57:29: previous declaration
;; src/github.com/golang/protobuf/proto/lib.go:465:6: EnumName redeclared in this block
;; /tmp/guix-build-go-github-com-prometheus-exporter-toolkit-web-0.8.2.drv-0/src/github.com/golang/protobuf/proto/deprecated.go:57:44: previous declaration
;; src/github.com/golang/protobuf/proto/lib.go:479:6: UnmarshalJSONEnum redeclared in this block
;; /tmp/guix-build-go-github-com-prometheus-exporter-toolkit-web-0.8.2.drv-0/src/github.com/golang/protobuf/proto/deprecated.go:66:82: previous declaration
(define-public go-github-com-prometheus-exporter-toolkit-web
  (package
    (name "go-github-com-prometheus-exporter-toolkit-web")
    (version "0.8.2")
    (home-page (string-append "https://github.com/prometheus/exporter-toolkit/tree/v" version "/web"))
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/prometheus/exporter-toolkit")
             (commit (string-append "v" version))))
       (file-name (git-file-name name version))
       (sha256 (base32 "07qib1prcrzdl2p1w5icq5mvw796q2aadhps3m7rj72mn08wv97f"))))
    (build-system go-build-system)
    (arguments '(#:import-path "github.com/prometheus/exporter-toolkit/web"
                 #:unpack-path "github.com/prometheus/exporter-toolkit"))
    (propagated-inputs (list go-github-com-go-kit-log
                             go-golang-org-x-crypto
                             go-golang-org-x-sync
                             go-gopkg-in-yaml-v2
                             go-github-com-coreos-go-systemd-v22-activation
                             go-github-com-mwitkow-go-conntrack
                             ;; The version from (gnu packages syncthing) is much too old, so update.
                             go-github-com-prometheus-common-latest
                             go-github-com-golang-protobuf-latest
                             go-github-com-golang-protobuf-ptypes-timestamp))
    (synopsis "Utility package to build Prometheus exporters")
    (description "This is a Go library for
@url{https://prometheus.io/docs/introduction/glossary/#exporter, Prometheus
exporters}.

This repository is meant to be used in combination with the
@url{https://github.com/prometheus/client_golang, @code{client_golang}}
repository.  If you are
@url{https://prometheus.io/docs/introduction/glossary/#direct-instrumentation,
instrumenting} an existing Go application, @code{client_golang} is the
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."))

(define-public go-k8s-io-client-go-util-jsonpath
  (package
    (name "go-k8s-io-client-go-util-jsonpath")
    ;; 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 (string-append "https://github.com/kubernetes/client-go/tree/v"
                              version "/util/jsonpath"))
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
             (url "https://github.com/kubernetes/client-go")
             (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/util/jsonpath"
                 #:unpack-path "k8s.io/client-go"))
    (synopsis "JSONPath module from Go client for Kubernetes")
    (description "The @code{util/jsonpath} module taken from the Kubernetes Go
client.")
    (license license:asl2.0)))

;; `go-github-com-alecthomas-kingpin' doesn't work for json-exporter; we need
;; gopkg.in/alecthomas/kingpin.v2.  We can reuse the existing package.
(define-public go-gopkg-in-alecthomas-kingpin
  (package
    (inherit go-github-com-alecthomas-kingpin)
    (name "go-gopkg-in-alecthomas-kingpin")
    (arguments '(#:import-path "gopkg.in/alecthomas/kingpin.v2"))))

(define-public prometheus-json-exporter
  (package
    (name "prometheus-json-exporter")
    (version "0.5.0")
    (home-page "https://github.com/prometheus-community/json_exporter")
    (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 "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"
                 #:install-source? #f))
    (inputs (list go-github-com-masterminds-sprig-v3
                  go-github-com-masterminds-goutils
                  go-github-com-masterminds-semver-v3
                  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))
    (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}.

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)))