monitoring: generator docs, move definitions to subpackage (#16214)

* 📖 Rendered monitoring package reference
*  Monitoring generator highlights + intro to dev
* ➡️ Migrate all definitions to a separate package for clarity and ease of documentation
This commit is contained in:
Robert Lin 2020-11-28 14:04:42 +08:00 committed by GitHub
parent 8e89dc3e31
commit 8996be69ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 1515 additions and 306 deletions

View File

@ -29,3 +29,4 @@ docker-images/grafana/config/provisioning/dashboards/sourcegraph/
storybook-static/
browser/code-intel-extensions/
!/.storybook/**
monitoring/monitoring/README.md

File diff suppressed because it is too large Load Diff

7
go.mod
View File

@ -121,8 +121,6 @@ require (
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f
github.com/neelance/parallel v0.0.0-20160708114440-4de9ce63d14c
github.com/onsi/ginkgo v1.12.1 // indirect
github.com/onsi/gomega v1.10.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opentracing-contrib/go-stdlib v1.0.0
github.com/opentracing/opentracing-go v1.2.0
@ -130,6 +128,7 @@ require (
github.com/peterhellberg/link v1.1.0
github.com/pkg/errors v0.9.1
github.com/pquerna/cachecontrol v0.0.0-20200819021114-67c6ae64274f // indirect
github.com/princjef/gomarkdoc v0.1.2
github.com/prometheus/alertmanager v0.21.0
github.com/prometheus/client_golang v1.6.0
github.com/prometheus/common v0.10.0
@ -184,10 +183,10 @@ require (
go.uber.org/atomic v1.7.0
go.uber.org/automaxprocs v1.3.0
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
golang.org/x/net v0.0.0-20200930145003-4acb6c075d10
golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
golang.org/x/sys v0.0.0-20200915084602-288bc346aa39
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
golang.org/x/tools v0.0.0-20200915031644-64986481280e
google.golang.org/api v0.29.0

50
go.sum
View File

@ -80,6 +80,8 @@ github.com/RoaringBitmap/roaring v0.5.1/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06M
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
@ -171,6 +173,10 @@ github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cheggaaa/pb v2.0.7+incompatible h1:gLKifR1UkZ/kLkda5gC0K6c8g+jU2sINPtBeOiNlMhU=
github.com/cheggaaa/pb v2.0.7+incompatible/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
github.com/cheggaaa/pb/v3 v3.0.4 h1:QZEPYOj2ix6d5oEg63fbHmpolrnNiwjUsk+h74Yt4bM=
github.com/cheggaaa/pb/v3 v3.0.4/go.mod h1:7rgWxLrAUcFMkvJuv09+DYi7mMUYi8nO9iOWcvGJPfw=
github.com/chris-ramon/douceur v0.2.0 h1:IDMEdxlEUUBYBKE4z/mJnFyVXox+MjuEVDJNN27glkU=
github.com/chris-ramon/douceur v0.2.0/go.mod h1:wDW5xjJdeoMm1mRt4sD4c/LbF/mWdEpRXQKjTR8nIBE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
@ -918,11 +924,13 @@ github.com/markbates/pkger v0.15.1/go.mod h1:0JoVlrol20BSywW79rN3kdFFsE5xYM+rSCQ
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb h1:RHba4YImhrUVQDHUCe2BNSOz4tVy2yGyXhvYDvxGgeE=
github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s=
github.com/matryer/is v1.3.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.0.10-0.20170816031813-ad5389df28cd/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
@ -943,6 +951,7 @@ github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOA
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
@ -1038,6 +1047,8 @@ github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU=
github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
github.com/onsi/ginkgo v1.12.1 h1:mFwc4LvZ0xpSvDZ3E+k8Yte0hLOMxXUlP+yXtJqkYfQ=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M=
github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
@ -1045,8 +1056,9 @@ github.com/onsi/gomega v1.8.1 h1:C5Dqfs/LeauYDX0jJXIe2SWmwCbGzx9yF8C8xy3Lh34=
github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
github.com/onsi/gomega v1.9.0 h1:R1uwffexN6Pr340GtYRIdZmAiN4J+iw6WG4wog1DUXg=
github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
github.com/onsi/gomega v1.10.0 h1:Gwkk+PTu/nfOwNMtUB/mRUv0X7ewW5dO4AERT1ThVKo=
github.com/onsi/gomega v1.10.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA=
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ=
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
@ -1101,6 +1113,10 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/pquerna/cachecontrol v0.0.0-20200819021114-67c6ae64274f h1:JDEmUDtyiLMyMlFwiaDOv2hxUp35497fkwePcLeV7j4=
github.com/pquerna/cachecontrol v0.0.0-20200819021114-67c6ae64274f/go.mod h1:hoLfEwdY11HjRfKFH6KqnPsfxlo3BP6bJehpDv8t6sQ=
github.com/princjef/gomarkdoc v0.1.2 h1:c8y26+xJsxsCZEnct3v25tcQ4uAw7JBcAQcKQ92hHkg=
github.com/princjef/gomarkdoc v0.1.2/go.mod h1:+fITxh0FqQpx1hlnpupF7nhnd5hj7yo/4bZptiDUZ/Y=
github.com/princjef/mageutil v0.1.0 h1:WXB92nDhPh8oKR7woRWCriDFeF75mYZ6JwDUxo8DJ34=
github.com/princjef/mageutil v0.1.0/go.mod h1:mkShhaUomCYfAoVvTKRcbAs8YSVPdtezI5j6K+VXhrs=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
@ -1265,24 +1281,31 @@ github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0b
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v0.0.0-20170901052352-ee1bd8ee15a1/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/cast v1.1.0/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/cobra v0.0.6 h1:breEStsVwemnKh2/s6gMvSdMEkwW0sK8vGStnlVBMCs=
github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE=
github.com/spf13/jwalterweatherman v0.0.0-20170901151539-12bd96e66386/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/pflag v1.0.1-0.20170901120850-7aff26db30c1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.0.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
github.com/spf13/viper v1.5.0/go.mod h1:AkYRkVJF8TkSG/xet6PzXX+l39KhhXa2pdqVSxnTcn4=
github.com/spf13/viper v1.6.1/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k=
github.com/spf13/viper v1.6.2 h1:7aKfF+e8/k68gda3LOjo5RxiUqddoFxVq4BKBPrxk5E=
github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k=
github.com/src-d/enry/v2 v2.1.0 h1:z1L8t+B8bh3mmjPkJrgOTnVRpFGmTPJsplHX9wAn6BI=
github.com/src-d/enry/v2 v2.1.0/go.mod h1:qQeCMRwzMF3ckeGr+h0tJLdxXnq+NVZsIDMELj0t028=
@ -1308,6 +1331,7 @@ github.com/stripe/stripe-go v70.15.0+incompatible h1:hNML7M1zx8RgtepEMlxyu/FpVPr
github.com/stripe/stripe-go v70.15.0+incompatible/go.mod h1:A1dQZmO/QypXmsL0T8axYZkSN/uA/T/A64pfKdBAMiY=
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203 h1:QVqDTf3h2WHt08YuiTGPZLls0Wq99X9bWd0Q5ZSBesM=
github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203/go.mod h1:oqN97ltKNihBbwlX8dLpwxCl3+HnXKV/R0e+sRLd9C8=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/temoto/robotstxt v1.1.1 h1:Gh8RCs8ouX3hRSxxK7B1mO5RFByQ4CmJZDwgom++JaA=
github.com/temoto/robotstxt v1.1.1/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo=
@ -1362,6 +1386,8 @@ github.com/willf/bitset v1.1.11 h1:N7Z7E9UvjW+sGsEl7k/SJrvY2reP1A07MrGuCjIOjRE=
github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI=
github.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0 h1:3UeQBvD0TFrlVjOeLOBz+CPAI8dnbqNSVwUwRrkp7vQ=
github.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0/go.mod h1:IXCdmsXIht47RaVFLEdVnh1t+pgYtTAhQGj73kz+2DM=
github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg=
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
github.com/xanzy/go-gitlab v0.15.0/go.mod h1:8zdQa/ri1dfn8eS3Ir1SyfvOKlw7WBJ8DVThkpGiXrs=
github.com/xanzy/go-gitlab v0.28.0/go.mod h1:t4Bmvnxj7k37S4Y17lfLx+nLqkf/oQwT2HagfWKv5Og=
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
@ -1514,10 +1540,11 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200930145003-4acb6c075d10 h1:YfxMZzv3PjGonQYNUaeU2+DhAdqOxerQ30JFB6WgAXo=
golang.org/x/net v0.0.0-20200930145003-4acb6c075d10/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0 h1:wBouT66WTYFXdxfVdz9sVWARVd/2vfGcmI45D2gj45M=
golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20170517211232-f52d1811a629/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -1566,6 +1593,7 @@ golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -1582,9 +1610,10 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200409092240-59c9f1ba88fa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200915084602-288bc346aa39 h1:356XA7ITklAU2//sYkjFeco+dH1bCRD8XCJ9FIEsvo4=
golang.org/x/sys v0.0.0-20200915084602-288bc346aa39/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -1754,6 +1783,7 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa
google.golang.org/grpc v1.28.1/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
google.golang.org/grpc v1.31.1 h1:SfXqXS5hkufcdZ/mHtYCh53P2b+92WQq/DZcKLgsFRs=
google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
gopkg.in/VividCortex/ewma.v1 v1.1.1/go.mod h1:TekXuFipeiHWiAlO1+wSS23vTcyFau5u3rxXUSXj710=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/alexcesaro/statsd.v2 v2.0.0 h1:FXkZSCZIH17vLCO5sO2UucTHsH9pc+17F6pl3JVCwMc=
gopkg.in/alexcesaro/statsd.v2 v2.0.0/go.mod h1:i0ubccKGzBVNBpdGV5MocxyA/XlLUJzA7SLonnE4drU=
@ -1764,18 +1794,26 @@ gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/cheggaaa/pb.v2 v2.0.7/go.mod h1:0CiZ1p8pvtxBlQpLXkHuUTpdJ1shm3OqCF1QugkjHL4=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fatih/color.v1 v1.7.0/go.mod h1:P7yosIhqIl/sX8J8UypY5M+dDpD2KmyfP5IRs5v/fo0=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec h1:RlWgLqCMMIYYEVcAR5MDsuHlVkaIPDAF+5Dehzg8L5A=
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.54.0 h1:oM5ElzbIi7gwLnNbPX2M25ED1vSAK3B6dex50eS/6Fs=
gopkg.in/ini.v1 v1.54.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/mattn/go-colorable.v0 v0.1.0/go.mod h1:BVJlBXzARQxdi3nZo6f6bnl5yR20/tOL6p+V0KejgSY=
gopkg.in/mattn/go-isatty.v0 v0.0.4/go.mod h1:wt691ab7g0X4ilKZNmMII3egK0bTxl37fEn/Fwbd8gc=
gopkg.in/mattn/go-runewidth.v0 v0.0.4/go.mod h1:BmXejnxvhwdaATwiJbB1vZ2dtXkQKZGu9yLFCZb4msQ=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/square/go-jose.v2 v2.5.1 h1:7odma5RETjNHWJnR32wx8t+Io4djHE1PqxCFx3iiZ2w=
gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg=
gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98=
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg=
gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g=
gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE=
gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8=

64
monitoring/README.md Normal file
View File

@ -0,0 +1,64 @@
# Sourcegraph monitoring generator
The Sourcegraph monitoring generator uses [`Container` definitions](./monitoring/README.md#type-container) to generate integrations with [Sourcegraph's monitoring architecture](https://about.sourcegraph.com/handbook/engineering/observability/monitoring_architecture).
It also aims to help codify guidelines defined in the [Sourcegraph monitoring pillars](https://about.sourcegraph.com/handbook/engineering/observability/monitoring_pillars).
This page primarily documents the [generator's current capabilities](#features) - in other words, and what you get for free by declaring Sourcegraph service monitoring in this package - as well as [how to make changes to the generator itself](#development).
To learn about how to find, add, and use monitoring, see the [Sourcegraph monitoring developer guide](https://about.sourcegraph.com/handbook/engineering/observability/monitoring).
## Usage
From this directory:
```sh
go generate ./...
```
## Features
### Documentation generation
The generator automatically creates documentation from monitoring definitions, such as [alert solutions references](https://docs.sourcegraph.com/admin/observability/alert_solutions), that customers and engineers can reference.
Links to generated documentation can be provided in our other generated integrations - for example, [Slack alerts](https://docs.sourcegraph.com/admin/observability/alerting#setting-up-alerting) will provide a link to the appropriate alert solutions entry.
### Grafana integration
The generator automatically generates and ships dashboards from monitoring definitions within the [Sourcegraph Grafana distribution](https://about.sourcegraph.com/handbook/engineering/observability/monitoring_architecture#sourcegraph-grafana).
It also takes care of the following:
- Graphs within rows are sized appropriately
- Alerts visualization through the [`ObservableAlertDefinition` API](./monitoring/README.md#type-observablealertdefinition):
- Overview graphs for alerts (both Sourcegraph-wide and per-service)
- Threshold lines for alerts of all levels are rendered in graphs
- Formatting of units, labels, and more (using either the defaults, or the [`ObservablePanelOptions` API](./monitoring/README.md#type-observablepaneloptions))
- Maintaining a uniform look and feel across all dashboards
Links to generated documentation can be provided in our other generated integrations - for example, [Slack alerts](https://docs.sourcegraph.com/admin/observability/alerting#setting-up-alerting) will provide a link to the appropriate service's dashboard.
### Prometheus integration
The generator automatically generates and ships Prometheus recording rules and alerts within the [Sourcegraph Prometheus distribution](https://about.sourcegraph.com/handbook/engineering/observability/monitoring_architecture#sourcegraph-prometheus). This includes the [`alert_count` recording rules](https://about.sourcegraph.com/handbook/engineering/observability/monitoring_architecture#alert-count-metrics) and native Prometheus alerts, all with appropriate and consistent labels.
Generated Prometheus recording rules are leveraged by the [Grafana integration](#grafana-integration).
### Alertmanager integration
The generator's [Prometheus integration](#prometheus-integration) is a critical part of the [Sourcegraph's alerting capabilities](https://about.sourcegraph.com/handbook/engineering/observability/monitoring_architecture#alert-notifications), which handles alert routing by level and formatting of alert messages to include links to [documentation](#documentation-generation) and [dashboards](#grafana-integration). Learn more about using Sourcegraph alerting in the [alerting documentation](https://docs.sourcegraph.com/admin/observability/alerting).
At Sourcegraph, routing based on team ownership (as defined by [`ObservableOwner`](./monitoring/README.md#type-observableowner)) is used to route customer support requests and [on-call events through OpsGenie](https://about.sourcegraph.com/handbook/engineering/incidents/on_call).
## Development
The Sourcegraph monitoring generator consists of three components:
- The [main program](./main.go) - this is the primary entrypoint to the generator.
- _Definitions_, defined in the top-level [`monitoring/definitions` package](./definitions/).
This is where the all service monitoring definitions lives.
If you are editing monitoring, this is probably where you want to look - see the [Sourcegraph monitoring developer guide](https://about.sourcegraph.com/handbook/engineering/observability/monitoring).
- _Generator_, defined in the nested [`monitoring/monitoring` package](./monitoring/README.md) package.
This is where the API for service monitoring definitions is defined, as well as the generator code.
All features and capabilities for developed for the generator should align with the [Sourcegraph monitoring pillars](https://about.sourcegraph.com/handbook/engineering/observability/monitoring_pillars).

View File

@ -1,4 +1,4 @@
package main
package definitions
import "github.com/sourcegraph/sourcegraph/monitoring/monitoring"

View File

@ -1,4 +1,4 @@
package main
package definitions
import (
"time"

View File

@ -1,4 +1,4 @@
package main
package definitions
import (
"fmt"

View File

@ -1,4 +1,4 @@
package main
package definitions
import (
"time"

View File

@ -1,4 +1,4 @@
package main
package definitions
import "github.com/sourcegraph/sourcegraph/monitoring/monitoring"

View File

@ -1,4 +1,4 @@
package main
package definitions
import "github.com/sourcegraph/sourcegraph/monitoring/monitoring"

View File

@ -1,4 +1,4 @@
package main
package definitions
import "github.com/sourcegraph/sourcegraph/monitoring/monitoring"

View File

@ -1,4 +1,4 @@
package main
package definitions
import (
"fmt"

View File

@ -1,4 +1,4 @@
package main
package definitions
import (
"time"

View File

@ -1,4 +1,4 @@
package main
package definitions
import (
"fmt"

View File

@ -1,4 +1,4 @@
package main
package definitions
import "github.com/sourcegraph/sourcegraph/monitoring/monitoring"

View File

@ -1,4 +1,4 @@
package main
package definitions
import (
"time"

View File

@ -1,4 +1,4 @@
package main
package definitions
import (
"fmt"

View File

@ -1,4 +1,4 @@
package main
package definitions
import (
"fmt"

View File

@ -2,24 +2,27 @@
//go:generate /tmp/monitoring-generator
package main
import "github.com/sourcegraph/sourcegraph/monitoring/monitoring"
import (
"github.com/sourcegraph/sourcegraph/monitoring/definitions"
"github.com/sourcegraph/sourcegraph/monitoring/monitoring"
)
func main() {
// Runs the monitoring generator. Ensure that any dashboards created or removed are
// updated in the arguments here as required.
monitoring.Generate(
Frontend(),
GitServer(),
GitHubProxy(),
PreciseCodeIntelWorker(),
QueryRunner(),
RepoUpdater(),
Searcher(),
Symbols(),
SyntectServer(),
ZoektIndexServer(),
ZoektWebServer(),
Prometheus(),
ExecutorAndExecutorQueue(),
definitions.Frontend(),
definitions.GitServer(),
definitions.GitHubProxy(),
definitions.PreciseCodeIntelWorker(),
definitions.QueryRunner(),
definitions.RepoUpdater(),
definitions.Searcher(),
definitions.Symbols(),
definitions.SyntectServer(),
definitions.ZoektIndexServer(),
definitions.ZoektWebServer(),
definitions.Prometheus(),
definitions.ExecutorAndExecutorQueue(),
)
}

367
monitoring/monitoring/README.md Executable file
View File

@ -0,0 +1,367 @@
<!-- Code generated by gomarkdoc. DO NOT EDIT -->
# monitoring
```go
import "github.com/sourcegraph/sourcegraph/monitoring/monitoring"
```
Package monitoring declares types for Sourcegraph's monitoring generator as well as the generator implementation itself\.
To learn more about developing monitoring\, see the guide: https://about\.sourcegraph\.com/handbook/engineering/observability/monitoring
To learn more about the generator\, see the top\-level program: https://github\.com/sourcegraph/sourcegraph/tree/main/monitoring
## Index
- [func Generate(containers ...*Container)](<#func-generate>)
- [type Container](<#type-container>)
- [type Group](<#type-group>)
- [type Observable](<#type-observable>)
- [type ObservableAlertDefinition](<#type-observablealertdefinition>)
- [func Alert() *ObservableAlertDefinition](<#func-alert>)
- [func (a *ObservableAlertDefinition) For(d time.Duration) *ObservableAlertDefinition](<#func-observablealertdefinition-for>)
- [func (a *ObservableAlertDefinition) GreaterOrEqual(f float64) *ObservableAlertDefinition](<#func-observablealertdefinition-greaterorequal>)
- [func (a *ObservableAlertDefinition) LessOrEqual(f float64) *ObservableAlertDefinition](<#func-observablealertdefinition-lessorequal>)
- [type ObservableOwner](<#type-observableowner>)
- [type ObservablePanelOptions](<#type-observablepaneloptions>)
- [func PanelOptions() ObservablePanelOptions](<#func-paneloptions>)
- [func (p ObservablePanelOptions) Interval(ms int) ObservablePanelOptions](<#func-observablepaneloptions-interval>)
- [func (p ObservablePanelOptions) LegendFormat(format string) ObservablePanelOptions](<#func-observablepaneloptions-legendformat>)
- [func (p ObservablePanelOptions) Max(max float64) ObservablePanelOptions](<#func-observablepaneloptions-max>)
- [func (p ObservablePanelOptions) Min(min float64) ObservablePanelOptions](<#func-observablepaneloptions-min>)
- [func (p ObservablePanelOptions) MinAuto() ObservablePanelOptions](<#func-observablepaneloptions-minauto>)
- [func (p ObservablePanelOptions) Unit(t UnitType) ObservablePanelOptions](<#func-observablepaneloptions-unit>)
- [type Row](<#type-row>)
- [type UnitType](<#type-unittype>)
## func [Generate](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/generator.go#L25>)
```go
func Generate(containers ...*Container)
```
Generate is the main Sourcegraph monitoring generator entrypoint\.
## type [Container](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L22-L35>)
Container describes a Docker container to be observed\.
These correspond to dashboards in Grafana\.
```go
type Container struct {
// Name of the Docker container, e.g. "syntect-server".
Name string
// Title of the Docker container, e.g. "Syntect Server".
Title string
// Description of the Docker container. It should describe what the container
// is responsible for, so that the impact of issues in it is clear.
Description string
// Groups of observable information about the container.
Groups []Group
}
```
## type [Group](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L58-L73>)
Group describes a group of observable information about a container\.
These correspond to collapsible sections in a Grafana dashboard\.
```go
type Group struct {
// Title of the group, briefly summarizing what this group is about, or
// "General" if the group is just about the container in general.
Title string
// Hidden indicates whether or not the group should be hidden by default.
//
// This should only be used when the dashboard is already full of information
// and the information presented in this group is unlikely to be the cause of
// issues and should generally only be inspected in the event that an alert
// for that information is firing.
Hidden bool
// Rows of observable metrics.
Rows []Row
}
```
## type [Observable](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L121-L219>)
Observable describes a metric about a container that can be observed\. For example\, memory usage\.
These correspond to Grafana graphs\.
```go
type Observable struct {
// Name is a short and human-readable lower_snake_case name describing what is being observed.
//
// It must be unique relative to the service name.
//
// Good examples:
//
// github_rate_limit_remaining
// search_error_rate
//
// Bad examples:
//
// repo_updater_github_rate_limit
// search_error_rate_over_5m
//
Name string
// Description is a human-readable description of exactly what is being observed.
//
// Good examples:
//
// "remaining GitHub API rate limit quota"
// "number of search errors every 5m"
// "90th percentile search request duration over 5m"
//
// Bad examples:
//
// "GitHub rate limit"
// "search errors[5m]"
// "P90 search latency"
//
Description string
// Owner indicates the team that owns any alerts associated with this Observable.
Owner ObservableOwner
// Query is the actual Prometheus query that should be observed.
Query string
// DataMayNotExist indicates if the query may not return data until some event occurs in the
// future.
//
// For example, repo_updater_memory_usage should always have data present and an alert should
// fire if for some reason that query is not returning any data, so this would be set to false.
// In contrast, search_error_rate would depend on users actually performing searches and we
// would not want an alert to fire if no data was present, so this would be set to true.
DataMayNotExist bool
// DataMayNotBeNaN indicates whether or not the query may return NaN regularly.
// In other words, when true, alerts will fire if the query returns NaN.
//
// NaN often indicates a mistaken divide by zero - for many types of alert queries,
// this is a common problem on low-traffic deployments where the values of many
// metrics frequently end up being 0, so the default is to allow it.
//
// However, for some queries NaN values may be unexpected, in which case you should
// set this to true.
DataMayNotBeNaN bool
// Warning and Critical alert definitions.
// Consider adding at least a Warning or Critical alert to each Observable to make it easy to
// identify when the target of this metric is missbehaving.
Warning, Critical *ObservableAlertDefinition
// NoAlerts is used by Observables that don't need any alerts.
// We want to be explicit about this to ensure alerting is considered and if we choose not to Alert,
// its easy to identify it is an intentional behavior.
NoAlert bool
// PossibleSolutions is Markdown describing possible solutions in the event that the alert is
// firing. If there is no clear potential resolution, "none" must be explicitly stated.
//
// Contacting support should not be mentioned as part of a possible solution, as it is
// communicated elsewhere.
//
// To make writing the Markdown more friendly in Go, string literals like this:
//
// Observable{
// PossibleSolutions: `
// - Foobar 'some code'
// `
// }
//
// Becomes:
//
// - Foobar `some code`
//
// In other words:
//
// 1. The preceding newline is removed.
// 2. The indentation in the string literal is removed (based on the last line).
// 3. Single quotes become backticks.
// 4. The last line (which is all indention) is removed.
//
PossibleSolutions string
// PanelOptions describes some options for how to render the metric in the Grafana panel.
PanelOptions ObservablePanelOptions
}
```
## type [ObservableAlertDefinition](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L255-L267>)
ObservableAlertDefinition defines when an alert would be considered firing\.
```go
type ObservableAlertDefinition struct {
// contains filtered or unexported fields
}
```
### func [Alert](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L250>)
```go
func Alert() *ObservableAlertDefinition
```
Alert provides a builder for defining alerting on an Observable\.
### func \(\*ObservableAlertDefinition\) [For](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L279>)
```go
func (a *ObservableAlertDefinition) For(d time.Duration) *ObservableAlertDefinition
```
### func \(\*ObservableAlertDefinition\) [GreaterOrEqual](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L269>)
```go
func (a *ObservableAlertDefinition) GreaterOrEqual(f float64) *ObservableAlertDefinition
```
### func \(\*ObservableAlertDefinition\) [LessOrEqual](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L274>)
```go
func (a *ObservableAlertDefinition) LessOrEqual(f float64) *ObservableAlertDefinition
```
## type [ObservableOwner](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L106>)
ObservableOwner denotes a team that owns an Observable\. The current teams are described in the handbook: https://about\.sourcegraph\.com/company/team/org\_chart\#engineering
```go
type ObservableOwner string
```
```go
const (
ObservableOwnerSearch ObservableOwner = "search"
ObservableOwnerCampaigns ObservableOwner = "campaigns"
ObservableOwnerCodeIntel ObservableOwner = "code-intel"
ObservableOwnerDistribution ObservableOwner = "distribution"
ObservableOwnerSecurity ObservableOwner = "security"
ObservableOwnerWeb ObservableOwner = "web"
ObservableOwnerCloud ObservableOwner = "cloud"
)
```
## type [ObservablePanelOptions](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L333-L339>)
```go
type ObservablePanelOptions struct {
// contains filtered or unexported fields
}
```
### func [PanelOptions](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L404>)
```go
func PanelOptions() ObservablePanelOptions
```
PanelOptions provides a builder for customizing an Observable\.
### func \(ObservablePanelOptions\) [Interval](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L375>)
```go
func (p ObservablePanelOptions) Interval(ms int) ObservablePanelOptions
```
### func \(ObservablePanelOptions\) [LegendFormat](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L364>)
```go
func (p ObservablePanelOptions) LegendFormat(format string) ObservablePanelOptions
```
LegendFormat sets the panel's legend format\, which may use Go template strings to select labels from the Prometheus query\.
### func \(ObservablePanelOptions\) [Max](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L357>)
```go
func (p ObservablePanelOptions) Max(max float64) ObservablePanelOptions
```
Max sets the maximum value of the Y axis on the panel\. The default is auto\.
### func \(ObservablePanelOptions\) [Min](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L342>)
```go
func (p ObservablePanelOptions) Min(min float64) ObservablePanelOptions
```
Min sets the minimum value of the Y axis on the panel\. The default is zero\.
### func \(ObservablePanelOptions\) [MinAuto](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L351>)
```go
func (p ObservablePanelOptions) MinAuto() ObservablePanelOptions
```
Min sets the minimum value of the Y axis on the panel to auto\, instead of the default zero\.
This is generally only useful if trying to show negative numbers\.
### func \(ObservablePanelOptions\) [Unit](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L370>)
```go
func (p ObservablePanelOptions) Unit(t UnitType) ObservablePanelOptions
```
Unit sets the panel's Y axis unit type\.
## type [Row](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L90>)
Row of observable metrics\.
These correspond to a row of Grafana graphs\.
```go
type Row []Observable
```
## type [UnitType](<https://github.com/sourcegraph/sourcegraph/blob/main/monitoring/monitoring/monitoring.go#L289>)
UnitType for controlling the unit type display on graphs\.
```go
type UnitType string
```
From https://sourcegraph\.com/github\.com/grafana/grafana@b63b82976b3708b082326c0b7d42f38d4bc261fa/\-/blob/packages/grafana\-data/src/valueFormats/categories\.ts\#L23
```go
const (
// Number is the default unit type.
Number UnitType = "short"
// Milliseconds for representing time.
Milliseconds UnitType = "dtdurationms"
// Seconds for representing time.
Seconds UnitType = "dtdurations"
// Percentage in the range of 0-100.
Percentage UnitType = "percent"
// Bytes in IEC (1024) format, e.g. for representing storage sizes.
Bytes UnitType = "bytes"
// BitsPerSecond, e.g. for representing network and disk IO.
BitsPerSecond UnitType = "bps"
)
```
Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)

View File

@ -0,0 +1,12 @@
/*
Package monitoring declares types for Sourcegraph's monitoring generator as well as the generator implementation itself.
To learn more about developing monitoring, see the guide: https://about.sourcegraph.com/handbook/engineering/observability/monitoring
To learn more about the generator, see the top-level program: https://github.com/sourcegraph/sourcegraph/tree/main/monitoring
*/
package monitoring
//go:generate go run github.com/princjef/gomarkdoc/cmd/gomarkdoc . -o README.md
import _ "github.com/princjef/gomarkdoc" // Pin version of godoc-to-markdown generator

View File

@ -1,5 +1,3 @@
// Package monitoring declares types for Sourcegraph's monitoring generator as well as the generator implementation itself.
//nolint:golint,gocritic
package monitoring
import (
@ -19,6 +17,8 @@ import (
)
// Container describes a Docker container to be observed.
//
// These correspond to dashboards in Grafana.
type Container struct {
// Name of the Docker container, e.g. "syntect-server".
Name string
@ -53,6 +53,8 @@ func (c *Container) validate() error {
}
// Group describes a group of observable information about a container.
//
// These correspond to collapsible sections in a Grafana dashboard.
type Group struct {
// Title of the group, briefly summarizing what this group is about, or
// "General" if the group is just about the container in general.
@ -83,6 +85,8 @@ func (g Group) validate() error {
}
// Row of observable metrics.
//
// These correspond to a row of Grafana graphs.
type Row []Observable
func (r Row) validate() error {
@ -112,6 +116,8 @@ const (
)
// Observable describes a metric about a container that can be observed. For example, memory usage.
//
// These correspond to Grafana graphs.
type Observable struct {
// Name is a short and human-readable lower_snake_case name describing what is being observed.
//
@ -174,7 +180,7 @@ type Observable struct {
// Warning and Critical alert definitions.
// Consider adding at least a Warning or Critical alert to each Observable to make it easy to
// identify when the target of this metric is missbehaving.
Warning, Critical *alertDefinition
Warning, Critical *ObservableAlertDefinition
// NoAlerts is used by Observables that don't need any alerts.
// We want to be explicit about this to ensure alerting is considered and if we choose not to Alert,
@ -209,7 +215,7 @@ type Observable struct {
PossibleSolutions string
// PanelOptions describes some options for how to render the metric in the Grafana panel.
PanelOptions panelOptions
PanelOptions ObservablePanelOptions
}
func (o Observable) validate() error {
@ -240,12 +246,13 @@ func (o Observable) validate() error {
return nil
}
func Alert() *alertDefinition {
return &alertDefinition{}
// Alert provides a builder for defining alerting on an Observable.
func Alert() *ObservableAlertDefinition {
return &ObservableAlertDefinition{}
}
// alertDefinition defines when an alert would be considered firing.
type alertDefinition struct {
// ObservableAlertDefinition defines when an alert would be considered firing.
type ObservableAlertDefinition struct {
// GreaterOrEqual, when non-zero, indicates the alert should fire when
// greater or equal to this value.
greaterOrEqual *float64
@ -259,23 +266,23 @@ type alertDefinition struct {
duration time.Duration
}
func (a *alertDefinition) GreaterOrEqual(f float64) *alertDefinition {
func (a *ObservableAlertDefinition) GreaterOrEqual(f float64) *ObservableAlertDefinition {
a.greaterOrEqual = &f
return a
}
func (a *alertDefinition) LessOrEqual(f float64) *alertDefinition {
func (a *ObservableAlertDefinition) LessOrEqual(f float64) *ObservableAlertDefinition {
a.lessOrEqual = &f
return a
}
func (a *alertDefinition) For(d time.Duration) *alertDefinition {
func (a *ObservableAlertDefinition) For(d time.Duration) *ObservableAlertDefinition {
a.duration = d
return a
}
func (a *alertDefinition) isEmpty() bool {
return a == nil || (*a == alertDefinition{}) || (a.greaterOrEqual == nil && a.lessOrEqual == nil)
func (a *ObservableAlertDefinition) isEmpty() bool {
return a == nil || (*a == ObservableAlertDefinition{}) || (a.greaterOrEqual == nil && a.lessOrEqual == nil)
}
// UnitType for controlling the unit type display on graphs.
@ -323,7 +330,7 @@ const (
BitsPerSecond UnitType = "bps"
)
type panelOptions struct {
type ObservablePanelOptions struct {
min, max *float64
minAuto bool
legendFormat string
@ -332,7 +339,7 @@ type panelOptions struct {
}
// Min sets the minimum value of the Y axis on the panel. The default is zero.
func (p panelOptions) Min(min float64) panelOptions {
func (p ObservablePanelOptions) Min(min float64) ObservablePanelOptions {
p.min = &min
return p
}
@ -341,36 +348,36 @@ func (p panelOptions) Min(min float64) panelOptions {
// the default zero.
//
// This is generally only useful if trying to show negative numbers.
func (p panelOptions) MinAuto() panelOptions {
func (p ObservablePanelOptions) MinAuto() ObservablePanelOptions {
p.minAuto = true
return p
}
// Max sets the maximum value of the Y axis on the panel. The default is auto.
func (p panelOptions) Max(max float64) panelOptions {
func (p ObservablePanelOptions) Max(max float64) ObservablePanelOptions {
p.max = &max
return p
}
// LegendFormat sets the panel's legend format, which may use Go template strings to select
// labels from the Prometheus query.
func (p panelOptions) LegendFormat(format string) panelOptions {
func (p ObservablePanelOptions) LegendFormat(format string) ObservablePanelOptions {
p.legendFormat = format
return p
}
// Unit sets the panel's Y axis unit type.
func (p panelOptions) Unit(t UnitType) panelOptions {
func (p ObservablePanelOptions) Unit(t UnitType) ObservablePanelOptions {
p.unitType = t
return p
}
func (p panelOptions) Interval(ms int) panelOptions {
func (p ObservablePanelOptions) Interval(ms int) ObservablePanelOptions {
p.interval = fmt.Sprintf("%dms", ms)
return p
}
func (p panelOptions) withDefaults() panelOptions {
func (p ObservablePanelOptions) withDefaults() ObservablePanelOptions {
if p.min == nil && !p.minAuto {
defaultMin := 0.0
p.min = &defaultMin
@ -393,7 +400,8 @@ func (p panelOptions) withDefaults() panelOptions {
return p
}
func PanelOptions() panelOptions { return panelOptions{} }
// PanelOptions provides a builder for customizing an Observable.
func PanelOptions() ObservablePanelOptions { return ObservablePanelOptions{} }
// dashboard generates the Grafana dashboard for this container.
func (c *Container) dashboard() *sdk.Board {
@ -628,7 +636,7 @@ func (c *Container) dashboard() *sdk.Board {
}
// alertDescription generates an alert description for the specified coontainer's alert.
func (c *Container) alertDescription(o Observable, alert *alertDefinition) string {
func (c *Container) alertDescription(o Observable, alert *ObservableAlertDefinition) string {
if alert.isEmpty() {
panic("never here")
}
@ -667,7 +675,7 @@ func (c *Container) promAlertsFile() *promRulesFile {
for _, g := range c.Groups {
for _, r := range g.Rows {
for _, o := range r {
for level, a := range map[string]*alertDefinition{
for level, a := range map[string]*ObservableAlertDefinition{
"warning": o.Warning,
"critical": o.Critical,
} {
@ -683,11 +691,11 @@ func (c *Container) promAlertsFile() *promRulesFile {
// make sure the prometheus alert description only describes one bound
name = fmt.Sprintf("%s_%s", o.Name, bound)
if bound == "high" {
description = c.alertDescription(o, &alertDefinition{
description = c.alertDescription(o, &ObservableAlertDefinition{
greaterOrEqual: a.greaterOrEqual,
})
} else if bound == "low" {
description = c.alertDescription(o, &alertDefinition{
description = c.alertDescription(o, &ObservableAlertDefinition{
lessOrEqual: a.lessOrEqual,
})
} else {
@ -879,11 +887,11 @@ To learn more about Sourcegraph's alerting, see [our alerting documentation](htt
fmt.Fprintf(&b, `<p class="subtitle">%s: %s</p>`, o.Owner, o.Description)
// Render descriptions of various levels of this alert
fmt.Fprintf(&b, "**Descriptions:**\n\n")
fmt.Fprintf(&b, "\n\n**Descriptions:**\n\n")
var prometheusAlertNames []string
for _, alert := range []struct {
level string
threshold *alertDefinition
threshold *ObservableAlertDefinition
}{
{level: "warning", threshold: o.Warning},
{level: "critical", threshold: o.Critical},
@ -910,7 +918,7 @@ To learn more about Sourcegraph's alerting, see [our alerting documentation](htt
]`, strings.Join(prometheusAlertNames, ",\n")))
// Render break for readability
fmt.Fprint(&b, "<br />\n")
fmt.Fprint(&b, "<br />\n\n")
}
}
}