Compare commits

..

8 Commits

Author SHA1 Message Date
Paul Marbach
65e740fe9c Sparkline: Add warnings for invalid series, and add more test cases 2025-11-21 15:04:24 -05:00
Paul Marbach
7f100bf104 fix points mode rendering 2025-11-21 14:02:31 -05:00
Paul Marbach
76dfb8fbea Update Sparkline.test.tsx 2025-11-21 11:45:08 -05:00
Paul Marbach
19135016f9 remove unused import 2025-11-19 18:13:40 -05:00
Paul Marbach
6271b56247 add comments throughout for #112977 2025-11-19 18:03:28 -05:00
Paul Marbach
7aa58f690a refactor out utils, experiment with getting highlightIndex working 2025-11-19 17:55:40 -05:00
Paul Marbach
3e08e784c5 some tests for this case 2025-11-19 16:17:58 -05:00
Paul Marbach
f00b83f3b6 Sparkline: Prevent infinite loop when rendering a sparkline with a single value 2025-11-19 16:16:37 -05:00
473 changed files with 9998 additions and 13919 deletions

View File

@@ -181,9 +181,7 @@ linters:
- pkg: io/ioutil
desc: 'Deprecated: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details.'
- pkg: gopkg.in/yaml.v2
desc: use go.yaml.in/yaml/v3 instead
- pkg: gopkg.in/yaml.v3
desc: use go.yaml.in/yaml/v3 instead
desc: Grafana packages are not allowed to depend on gopkg.in/yaml.v2 as gopkg.in/yaml.v3 is now available
- pkg: github.com/pkg/errors
desc: 'Deprecated: Go 1.13 supports the functionality provided by pkg/errors in the standard library.'
- pkg: github.com/xorcare/pointer

View File

@@ -6,7 +6,7 @@ require (
github.com/Masterminds/semver/v3 v3.4.0
github.com/google/go-cmp v0.7.0
github.com/google/go-github/v70 v70.0.0
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37
github.com/grafana/grafana v0.0.0-00010101000000-000000000000
github.com/grafana/grafana-app-sdk v0.48.2
github.com/grafana/grafana-app-sdk/logging v0.48.1
@@ -62,7 +62,7 @@ require (
github.com/apache/arrow-go/v18 v18.4.1 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/at-wat/mqtt-go v0.19.6 // indirect
github.com/at-wat/mqtt-go v0.19.4 // indirect
github.com/aws/aws-sdk-go v1.55.7 // indirect
github.com/aws/aws-sdk-go-v2 v1.39.1 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.18.14 // indirect
@@ -147,7 +147,7 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/google/wire v0.7.0 // indirect
github.com/grafana/alerting v0.0.0-20251119204204-77fa75125181 // indirect
github.com/grafana/alerting v0.0.0-20251009192429-9427c24835ae // indirect
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f // indirect
github.com/grafana/dataplane/sdata v0.0.9 // indirect
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4 // indirect
@@ -232,7 +232,7 @@ require (
github.com/prometheus/alertmanager v0.28.0 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
github.com/prometheus/exporter-toolkit v0.14.0 // indirect
github.com/prometheus/procfs v0.16.1 // indirect

View File

@@ -166,8 +166,8 @@ github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so=
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
github.com/at-wat/mqtt-go v0.19.6 h1:+jo59yGHB3oqBU8nSFYbq6KDgN4ngMpqts5Qtyq61pc=
github.com/at-wat/mqtt-go v0.19.6/go.mod h1:Y/YrYwUlLE4N53//699Zir3WJnxSdJojvLEAbZxJjgQ=
github.com/at-wat/mqtt-go v0.19.4 h1:R2cbCU7O5PHQ38unbe1Y51ncG3KsFEJV6QeipDoqdLQ=
github.com/at-wat/mqtt-go v0.19.4/go.mod h1:AsiWc9kqVOhqq7LzUeWT/AkKUBfx3Sw5cEe8lc06fqA=
github.com/aws/aws-sdk-go v1.17.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
github.com/aws/aws-sdk-go v1.55.7 h1:UJrkFq7es5CShfBwlWAC8DA077vp8PyVbQd3lqLiztE=
@@ -647,12 +647,12 @@ github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z
github.com/gorilla/mux v1.7.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/grafana/alerting v0.0.0-20251119204204-77fa75125181 h1:nbxKRtrbuhvOYmI2RhOYauHRJCtpR+vTNIgg1lFUCws=
github.com/grafana/alerting v0.0.0-20251119204204-77fa75125181/go.mod h1:VtPNIFlEOJPPEc13Ax6ZTbNV3M/sAzLID72YjgzOPVA=
github.com/grafana/alerting v0.0.0-20251009192429-9427c24835ae h1:NLPwY3tIP0lg0g9wTRiMcypm6VRXW6W+MOLBsq8JSVA=
github.com/grafana/alerting v0.0.0-20251009192429-9427c24835ae/go.mod h1:VGjS5gDwWEADPP6pF/drqLxEImgeuHlEW5u8E5EfIrM=
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f h1:Cbm6OKkOcJ+7CSZsGsEJzktC/SIa5bxVeYKQLuYK86o=
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f/go.mod h1:axY0cdOg3q0TZHwpHnIz5x16xZ8ZBxJHShsSHHXcHQg=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4 h1:Muoy+FMGrHj3GdFbvsMzUT7eusgii9PKf9L1ZaXDDbY=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37 h1:qEwZ+7MbPjzRvTi31iT9w7NBhKIpKwZrFbYmOZLqkwA=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/dataplane/examples v0.0.1 h1:K9M5glueWyLoL4//H+EtTQq16lXuHLmOhb6DjSCahzA=
github.com/grafana/dataplane/examples v0.0.1/go.mod h1:h5YwY8s407/17XF5/dS8XrUtsTVV2RnuW8+m1Mp46mg=
github.com/grafana/dataplane/sdata v0.0.9 h1:AGL1LZnCUG4MnQtnWpBPbQ8ZpptaZs14w6kE/MWfg7s=
@@ -1046,8 +1046,8 @@ github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8b
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4=
github.com/prometheus/common/sigv4 v0.1.0/go.mod h1:2Jkxxk9yYvCkE5G1sQT7GuEXm57JrvHu9k5YwTjsNtI=
github.com/prometheus/exporter-toolkit v0.14.0 h1:NMlswfibpcZZ+H0sZBiTjrA3/aBFHkNZqE+iCj5EmRg=

View File

@@ -32,6 +32,7 @@ require (
github.com/go-openapi/swag/jsonname v0.25.1 // indirect
github.com/go-test/deep v1.1.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.7.0 // indirect
github.com/google/go-cmp v0.7.0 // indirect
@@ -59,7 +60,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/puzpuzpuz/xsync/v2 v2.5.1 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect

View File

@@ -140,8 +140,8 @@ github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=

View File

@@ -5,7 +5,7 @@ go 1.25.3
require (
github.com/grafana/grafana-app-sdk v0.48.2
github.com/grafana/grafana-app-sdk/logging v0.48.1
github.com/prometheus/common v0.67.3
github.com/prometheus/common v0.67.2
k8s.io/apimachinery v0.34.2
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912
)

View File

@@ -104,8 +104,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU=

View File

@@ -49,7 +49,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/puzpuzpuz/xsync/v2 v2.5.1 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect

View File

@@ -104,8 +104,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU=

View File

@@ -41,7 +41,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/woodsbury/decimal128 v1.3.0 // indirect

View File

@@ -85,8 +85,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=

View File

@@ -49,7 +49,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/puzpuzpuz/xsync/v2 v2.5.1 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect

View File

@@ -104,8 +104,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU=

View File

@@ -4,7 +4,7 @@ go 1.25.3
require (
cuelang.org/go v0.11.1
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37
github.com/grafana/grafana-app-sdk v0.48.2
github.com/grafana/grafana-app-sdk/logging v0.48.1
github.com/grafana/grafana-plugin-sdk-go v0.283.0
@@ -84,7 +84,7 @@ require (
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/spf13/pflag v1.0.10 // indirect

View File

@@ -81,8 +81,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f h1:Cbm6OKkOcJ+7CSZsGsEJzktC/SIa5bxVeYKQLuYK86o=
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f/go.mod h1:axY0cdOg3q0TZHwpHnIz5x16xZ8ZBxJHShsSHHXcHQg=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4 h1:Muoy+FMGrHj3GdFbvsMzUT7eusgii9PKf9L1ZaXDDbY=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37 h1:qEwZ+7MbPjzRvTi31iT9w7NBhKIpKwZrFbYmOZLqkwA=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4 h1:jSojuc7njleS3UOz223WDlXOinmuLAIPI0z2vtq8EgI=
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4/go.mod h1:VahT+GtfQIM+o8ht2StR6J9g+Ef+C2Vokh5uuSmOD/4=
github.com/grafana/grafana-app-sdk v0.48.2 h1:CQQDhwo1fWaXQVKvxxOcK6azbuY3E2TgJHNAZlYYn7U=
@@ -202,8 +202,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/protocolbuffers/txtpbfmt v0.0.0-20241112170944-20d2c9ebc01d h1:HWfigq7lB31IeJL8iy7jkUmU/PG1Sr8jVGhS749dbUA=

View File

@@ -66,9 +66,6 @@ func ValidateDashboardSpec(obj *Dashboard, forceValidation bool) (field.ErrorLis
}
func formatErrorPath(path []string) string {
if len(path) <= 4 {
return strings.Join(path, ".")
}
// omitting the "lineage.schemas[0].schema.spec" prefix here.
return strings.Join(path[4:], ".")
}

View File

@@ -67,9 +67,6 @@ func ValidateDashboardSpec(obj *Dashboard, forceValidation bool) (field.ErrorLis
}
func formatErrorPath(path []string) string {
if len(path) <= 4 {
return strings.Join(path, ".")
}
// omitting the "lineage.schemas[0].schema.spec" prefix here.
return strings.Join(path[4:], ".")
}

View File

@@ -11,13 +11,11 @@ import (
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
)
func RegisterConversions(s *runtime.Scheme, dsIndexProvider schemaversion.DataSourceIndexProvider, leIndexProvider schemaversion.LibraryElementIndexProvider) error {
func RegisterConversions(s *runtime.Scheme, dsIndexProvider schemaversion.DataSourceIndexProvider, _ schemaversion.LibraryElementIndexProvider) error {
// Wrap the provider once with 10s caching for all conversions.
// This prevents repeated DB queries across multiple conversion calls while allowing
// the cache to refresh periodically, making it suitable for long-lived singleton usage.
dsIndexProvider = schemaversion.WrapIndexProviderWithCache(dsIndexProvider)
// Wrap library element provider with caching as well
leIndexProvider = schemaversion.WrapLibraryElementProviderWithCache(leIndexProvider)
// v0 conversions
if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv1.Dashboard)(nil),
@@ -28,13 +26,13 @@ func RegisterConversions(s *runtime.Scheme, dsIndexProvider schemaversion.DataSo
}
if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv2alpha1.Dashboard)(nil),
withConversionMetrics(dashv0.APIVERSION, dashv2alpha1.APIVERSION, func(a, b interface{}, scope conversion.Scope) error {
return Convert_V0_to_V2alpha1(a.(*dashv0.Dashboard), b.(*dashv2alpha1.Dashboard), scope, dsIndexProvider, leIndexProvider)
return Convert_V0_to_V2alpha1(a.(*dashv0.Dashboard), b.(*dashv2alpha1.Dashboard), scope, dsIndexProvider)
})); err != nil {
return err
}
if err := s.AddConversionFunc((*dashv0.Dashboard)(nil), (*dashv2beta1.Dashboard)(nil),
withConversionMetrics(dashv0.APIVERSION, dashv2beta1.APIVERSION, func(a, b interface{}, scope conversion.Scope) error {
return Convert_V0_to_V2beta1(a.(*dashv0.Dashboard), b.(*dashv2beta1.Dashboard), scope, dsIndexProvider, leIndexProvider)
return Convert_V0_to_V2beta1(a.(*dashv0.Dashboard), b.(*dashv2beta1.Dashboard), scope, dsIndexProvider)
})); err != nil {
return err
}
@@ -48,13 +46,13 @@ func RegisterConversions(s *runtime.Scheme, dsIndexProvider schemaversion.DataSo
}
if err := s.AddConversionFunc((*dashv1.Dashboard)(nil), (*dashv2alpha1.Dashboard)(nil),
withConversionMetrics(dashv1.APIVERSION, dashv2alpha1.APIVERSION, func(a, b interface{}, scope conversion.Scope) error {
return Convert_V1beta1_to_V2alpha1(a.(*dashv1.Dashboard), b.(*dashv2alpha1.Dashboard), scope, dsIndexProvider, leIndexProvider)
return Convert_V1beta1_to_V2alpha1(a.(*dashv1.Dashboard), b.(*dashv2alpha1.Dashboard), scope, dsIndexProvider)
})); err != nil {
return err
}
if err := s.AddConversionFunc((*dashv1.Dashboard)(nil), (*dashv2beta1.Dashboard)(nil),
withConversionMetrics(dashv1.APIVERSION, dashv2beta1.APIVERSION, func(a, b interface{}, scope conversion.Scope) error {
return Convert_V1beta1_to_V2beta1(a.(*dashv1.Dashboard), b.(*dashv2beta1.Dashboard), scope, dsIndexProvider, leIndexProvider)
return Convert_V1beta1_to_V2beta1(a.(*dashv1.Dashboard), b.(*dashv2beta1.Dashboard), scope, dsIndexProvider)
})); err != nil {
return err
}

View File

@@ -33,8 +33,7 @@ import (
func TestConversionMatrixExist(t *testing.T) {
// Initialize the migrator with a test data source provider
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
// Use TestLibraryElementProvider for tests that need library panel models with repeat options
leProvider := migrationtestutil.NewTestLibraryElementProvider()
leProvider := migrationtestutil.NewLibraryElementProvider()
migration.Initialize(dsProvider, leProvider)
versions := []metav1.Object{
@@ -87,8 +86,7 @@ func TestDeepCopyValid(t *testing.T) {
func TestDashboardConversionToAllVersions(t *testing.T) {
// Initialize the migrator with a test data source provider
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
// Use TestLibraryElementProvider for tests that need library panel models with repeat options
leProvider := migrationtestutil.NewTestLibraryElementProvider()
leProvider := migrationtestutil.NewLibraryElementProvider()
migration.Initialize(dsProvider, leProvider)
// Set up conversion scheme
@@ -248,8 +246,7 @@ func TestDashboardConversionToAllVersions(t *testing.T) {
func TestMigratedDashboardsConversion(t *testing.T) {
// Initialize the migrator with a test data source provider
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
// Use TestLibraryElementProvider for tests that need library panel models with repeat options
leProvider := migrationtestutil.NewTestLibraryElementProvider()
leProvider := migrationtestutil.NewLibraryElementProvider()
migration.Initialize(dsProvider, leProvider)
// Set up conversion scheme
@@ -384,8 +381,7 @@ func testConversion(t *testing.T, convertedDash metav1.Object, filename, outputD
func TestConversionMetrics(t *testing.T) {
// Initialize migration with test providers
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
// Use TestLibraryElementProvider for tests that need library panel models with repeat options
leProvider := migrationtestutil.NewTestLibraryElementProvider()
leProvider := migrationtestutil.NewLibraryElementProvider()
migration.Initialize(dsProvider, leProvider)
// Create a test registry for metrics
@@ -513,8 +509,7 @@ func TestConversionMetrics(t *testing.T) {
// TestConversionMetricsWrapper tests the withConversionMetrics wrapper function
func TestConversionMetricsWrapper(t *testing.T) {
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
// Use TestLibraryElementProvider for tests that need library panel models with repeat options
leProvider := migrationtestutil.NewTestLibraryElementProvider()
leProvider := migrationtestutil.NewLibraryElementProvider()
migration.Initialize(dsProvider, leProvider)
// Create a test registry for metrics
@@ -683,8 +678,7 @@ func TestSchemaVersionExtraction(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
// Test the schema version extraction logic by creating a wrapper and checking the metrics labels
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
// Use TestLibraryElementProvider for tests that need library panel models with repeat options
leProvider := migrationtestutil.NewTestLibraryElementProvider()
leProvider := migrationtestutil.NewLibraryElementProvider()
migration.Initialize(dsProvider, leProvider)
// Create a test registry for metrics
@@ -729,8 +723,7 @@ func TestSchemaVersionExtraction(t *testing.T) {
// TestConversionLogging tests that conversion-level logging works correctly
func TestConversionLogging(t *testing.T) {
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
// Use TestLibraryElementProvider for tests that need library panel models with repeat options
leProvider := migrationtestutil.NewTestLibraryElementProvider()
leProvider := migrationtestutil.NewLibraryElementProvider()
migration.Initialize(dsProvider, leProvider)
// Create a test registry for metrics
@@ -822,8 +815,7 @@ func TestConversionLogging(t *testing.T) {
// TestConversionLogLevels tests that appropriate log levels are used
func TestConversionLogLevels(t *testing.T) {
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
// Use TestLibraryElementProvider for tests that need library panel models with repeat options
leProvider := migrationtestutil.NewTestLibraryElementProvider()
leProvider := migrationtestutil.NewLibraryElementProvider()
migration.Initialize(dsProvider, leProvider)
t.Run("log levels and structured fields verification", func(t *testing.T) {
@@ -895,8 +887,7 @@ func TestConversionLogLevels(t *testing.T) {
// TestConversionLoggingFields tests that all expected fields are included in log messages
func TestConversionLoggingFields(t *testing.T) {
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
// Use TestLibraryElementProvider for tests that need library panel models with repeat options
leProvider := migrationtestutil.NewTestLibraryElementProvider()
leProvider := migrationtestutil.NewLibraryElementProvider()
migration.Initialize(dsProvider, leProvider)
t.Run("verify all log fields are present", func(t *testing.T) {

View File

@@ -1,93 +0,0 @@
{
"kind": "Dashboard",
"apiVersion": "dashboard.grafana.app/v1beta1",
"metadata": {
"name": "library-panel-repeat-options-test",
"labels": {
"test": "library-panel-repeat"
}
},
"spec": {
"title": "Library Panel Repeat Options Test Dashboard",
"description": "Testing library panel repeat options migration from v1beta1 to v2alpha1",
"tags": ["test", "library-panels", "repeat"],
"schemaVersion": 38,
"panels": [
{
"id": 1,
"title": "Library Panel with Horizontal Repeat",
"type": "library-panel-ref",
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 8
},
"libraryPanel": {
"uid": "lib-panel-repeat-h",
"name": "Library Panel with Horizontal Repeat"
}
},
{
"id": 2,
"title": "Library Panel with Vertical Repeat",
"type": "library-panel-ref",
"gridPos": {
"x": 0,
"y": 8,
"w": 6,
"h": 4
},
"libraryPanel": {
"uid": "lib-panel-repeat-v",
"name": "Library Panel with Vertical Repeat"
}
},
{
"id": 3,
"title": "Library Panel Instance Override",
"type": "library-panel-ref",
"gridPos": {
"x": 6,
"y": 8,
"w": 12,
"h": 8
},
"libraryPanel": {
"uid": "lib-panel-repeat-h",
"name": "Library Panel with Horizontal Repeat"
},
"repeat": "instance-var",
"repeatDirection": "v",
"maxPerRow": 5
},
{
"id": 4,
"title": "Library Panel without Repeat",
"type": "library-panel-ref",
"gridPos": {
"x": 0,
"y": 12,
"w": 6,
"h": 3
},
"libraryPanel": {
"uid": "lib-panel-no-repeat",
"name": "Library Panel without Repeat"
}
}
],
"time": {
"from": "now-1h",
"to": "now"
},
"templating": {
"list": []
},
"annotations": {
"list": []
},
"links": []
}
}

View File

@@ -1,102 +0,0 @@
{
"kind": "Dashboard",
"apiVersion": "dashboard.grafana.app/v0alpha1",
"metadata": {
"name": "library-panel-repeat-options-test",
"labels": {
"test": "library-panel-repeat"
}
},
"spec": {
"annotations": {
"list": []
},
"description": "Testing library panel repeat options migration from v1beta1 to v2alpha1",
"links": [],
"panels": [
{
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"libraryPanel": {
"name": "Library Panel with Horizontal Repeat",
"uid": "lib-panel-repeat-h"
},
"title": "Library Panel with Horizontal Repeat",
"type": "library-panel-ref"
},
{
"gridPos": {
"h": 4,
"w": 6,
"x": 0,
"y": 8
},
"id": 2,
"libraryPanel": {
"name": "Library Panel with Vertical Repeat",
"uid": "lib-panel-repeat-v"
},
"title": "Library Panel with Vertical Repeat",
"type": "library-panel-ref"
},
{
"gridPos": {
"h": 8,
"w": 12,
"x": 6,
"y": 8
},
"id": 3,
"libraryPanel": {
"name": "Library Panel with Horizontal Repeat",
"uid": "lib-panel-repeat-h"
},
"maxPerRow": 5,
"repeat": "instance-var",
"repeatDirection": "v",
"title": "Library Panel Instance Override",
"type": "library-panel-ref"
},
{
"gridPos": {
"h": 3,
"w": 6,
"x": 0,
"y": 12
},
"id": 4,
"libraryPanel": {
"name": "Library Panel without Repeat",
"uid": "lib-panel-no-repeat"
},
"title": "Library Panel without Repeat",
"type": "library-panel-ref"
}
],
"schemaVersion": 38,
"tags": [
"test",
"library-panels",
"repeat"
],
"templating": {
"list": []
},
"time": {
"from": "now-1h",
"to": "now"
},
"title": "Library Panel Repeat Options Test Dashboard"
},
"status": {
"conversion": {
"failed": false,
"storedVersion": "v1beta1"
}
}
}

View File

@@ -1,169 +0,0 @@
{
"kind": "Dashboard",
"apiVersion": "dashboard.grafana.app/v2alpha1",
"metadata": {
"name": "library-panel-repeat-options-test",
"labels": {
"test": "library-panel-repeat"
}
},
"spec": {
"annotations": [],
"cursorSync": "Off",
"description": "Testing library panel repeat options migration from v1beta1 to v2alpha1",
"editable": true,
"elements": {
"panel-1": {
"kind": "LibraryPanel",
"spec": {
"id": 1,
"title": "Library Panel with Horizontal Repeat",
"libraryPanel": {
"name": "Library Panel with Horizontal Repeat",
"uid": "lib-panel-repeat-h"
}
}
},
"panel-2": {
"kind": "LibraryPanel",
"spec": {
"id": 2,
"title": "Library Panel with Vertical Repeat",
"libraryPanel": {
"name": "Library Panel with Vertical Repeat",
"uid": "lib-panel-repeat-v"
}
}
},
"panel-3": {
"kind": "LibraryPanel",
"spec": {
"id": 3,
"title": "Library Panel Instance Override",
"libraryPanel": {
"name": "Library Panel with Horizontal Repeat",
"uid": "lib-panel-repeat-h"
}
}
},
"panel-4": {
"kind": "LibraryPanel",
"spec": {
"id": 4,
"title": "Library Panel without Repeat",
"libraryPanel": {
"name": "Library Panel without Repeat",
"uid": "lib-panel-no-repeat"
}
}
}
},
"layout": {
"kind": "GridLayout",
"spec": {
"items": [
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 0,
"width": 12,
"height": 8,
"element": {
"kind": "ElementReference",
"name": "panel-1"
},
"repeat": {
"mode": "variable",
"value": "server",
"direction": "h",
"maxPerRow": 3
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 8,
"width": 6,
"height": 4,
"element": {
"kind": "ElementReference",
"name": "panel-2"
},
"repeat": {
"mode": "variable",
"value": "datacenter",
"direction": "v"
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 6,
"y": 8,
"width": 12,
"height": 8,
"element": {
"kind": "ElementReference",
"name": "panel-3"
},
"repeat": {
"mode": "variable",
"value": "instance-var",
"direction": "v",
"maxPerRow": 5
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 12,
"width": 6,
"height": 3,
"element": {
"kind": "ElementReference",
"name": "panel-4"
}
}
}
]
}
},
"links": [],
"liveNow": false,
"preload": false,
"tags": [
"test",
"library-panels",
"repeat"
],
"timeSettings": {
"timezone": "browser",
"from": "now-1h",
"to": "now",
"autoRefresh": "",
"autoRefreshIntervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"hideTimepicker": false,
"fiscalYearStartMonth": 0
},
"title": "Library Panel Repeat Options Test Dashboard",
"variables": []
},
"status": {}
}

View File

@@ -1,169 +0,0 @@
{
"kind": "Dashboard",
"apiVersion": "dashboard.grafana.app/v2beta1",
"metadata": {
"name": "library-panel-repeat-options-test",
"labels": {
"test": "library-panel-repeat"
}
},
"spec": {
"annotations": [],
"cursorSync": "Off",
"description": "Testing library panel repeat options migration from v1beta1 to v2alpha1",
"editable": true,
"elements": {
"panel-1": {
"kind": "LibraryPanel",
"spec": {
"id": 1,
"title": "Library Panel with Horizontal Repeat",
"libraryPanel": {
"name": "Library Panel with Horizontal Repeat",
"uid": "lib-panel-repeat-h"
}
}
},
"panel-2": {
"kind": "LibraryPanel",
"spec": {
"id": 2,
"title": "Library Panel with Vertical Repeat",
"libraryPanel": {
"name": "Library Panel with Vertical Repeat",
"uid": "lib-panel-repeat-v"
}
}
},
"panel-3": {
"kind": "LibraryPanel",
"spec": {
"id": 3,
"title": "Library Panel Instance Override",
"libraryPanel": {
"name": "Library Panel with Horizontal Repeat",
"uid": "lib-panel-repeat-h"
}
}
},
"panel-4": {
"kind": "LibraryPanel",
"spec": {
"id": 4,
"title": "Library Panel without Repeat",
"libraryPanel": {
"name": "Library Panel without Repeat",
"uid": "lib-panel-no-repeat"
}
}
}
},
"layout": {
"kind": "GridLayout",
"spec": {
"items": [
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 0,
"width": 12,
"height": 8,
"element": {
"kind": "ElementReference",
"name": "panel-1"
},
"repeat": {
"mode": "variable",
"value": "server",
"direction": "h",
"maxPerRow": 3
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 8,
"width": 6,
"height": 4,
"element": {
"kind": "ElementReference",
"name": "panel-2"
},
"repeat": {
"mode": "variable",
"value": "datacenter",
"direction": "v"
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 6,
"y": 8,
"width": 12,
"height": 8,
"element": {
"kind": "ElementReference",
"name": "panel-3"
},
"repeat": {
"mode": "variable",
"value": "instance-var",
"direction": "v",
"maxPerRow": 5
}
}
},
{
"kind": "GridLayoutItem",
"spec": {
"x": 0,
"y": 12,
"width": 6,
"height": 3,
"element": {
"kind": "ElementReference",
"name": "panel-4"
}
}
}
]
}
},
"links": [],
"liveNow": false,
"preload": false,
"tags": [
"test",
"library-panels",
"repeat"
],
"timeSettings": {
"timezone": "browser",
"from": "now-1h",
"to": "now",
"autoRefresh": "",
"autoRefreshIntervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"hideTimepicker": false,
"fiscalYearStartMonth": 0
},
"title": "Library Panel Repeat Options Test Dashboard",
"variables": []
},
"status": {}
}

View File

@@ -25,7 +25,7 @@ func Convert_V0_to_V1beta1(in *dashv0.Dashboard, out *dashv1.Dashboard, scope co
return nil
}
func Convert_V0_to_V2alpha1(in *dashv0.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope, dsIndexProvider schemaversion.DataSourceIndexProvider, leIndexProvider schemaversion.LibraryElementIndexProvider) error {
func Convert_V0_to_V2alpha1(in *dashv0.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope, dsIndexProvider schemaversion.DataSourceIndexProvider) error {
v1beta1 := &dashv1.Dashboard{}
if err := ConvertDashboard_V0_to_V1beta1(in, v1beta1, scope); err != nil {
out.Status = dashv2alpha1.DashboardStatus{
@@ -48,7 +48,7 @@ func Convert_V0_to_V2alpha1(in *dashv0.Dashboard, out *dashv2alpha1.Dashboard, s
return nil
}
if err := ConvertDashboard_V1beta1_to_V2alpha1(v1beta1, out, scope, dsIndexProvider, leIndexProvider); err != nil {
if err := ConvertDashboard_V1beta1_to_V2alpha1(v1beta1, out, scope, dsIndexProvider); err != nil {
out.Status = dashv2alpha1.DashboardStatus{
Conversion: &dashv2alpha1.DashboardConversionStatus{
StoredVersion: ptr.To(dashv0.VERSION),
@@ -72,7 +72,7 @@ func Convert_V0_to_V2alpha1(in *dashv0.Dashboard, out *dashv2alpha1.Dashboard, s
return nil
}
func Convert_V0_to_V2beta1(in *dashv0.Dashboard, out *dashv2beta1.Dashboard, scope conversion.Scope, dsIndexProvider schemaversion.DataSourceIndexProvider, leIndexProvider schemaversion.LibraryElementIndexProvider) error {
func Convert_V0_to_V2beta1(in *dashv0.Dashboard, out *dashv2beta1.Dashboard, scope conversion.Scope, dsIndexProvider schemaversion.DataSourceIndexProvider) error {
v1beta1 := &dashv1.Dashboard{}
if err := ConvertDashboard_V0_to_V1beta1(in, v1beta1, scope); err != nil {
out.Status = dashv2beta1.DashboardStatus{
@@ -86,7 +86,7 @@ func Convert_V0_to_V2beta1(in *dashv0.Dashboard, out *dashv2beta1.Dashboard, sco
}
v2alpha1 := &dashv2alpha1.Dashboard{}
if err := ConvertDashboard_V1beta1_to_V2alpha1(v1beta1, v2alpha1, scope, dsIndexProvider, leIndexProvider); err != nil {
if err := ConvertDashboard_V1beta1_to_V2alpha1(v1beta1, v2alpha1, scope, dsIndexProvider); err != nil {
out.Status = dashv2beta1.DashboardStatus{
Conversion: &dashv2beta1.DashboardConversionStatus{
StoredVersion: ptr.To(dashv0.VERSION),

View File

@@ -109,9 +109,9 @@ func TestV0ConversionErrorHandling(t *testing.T) {
case *dashv1.Dashboard:
err = Convert_V0_to_V1beta1(tt.source, target, nil)
case *dashv2alpha1.Dashboard:
err = Convert_V0_to_V2alpha1(tt.source, target, nil, dsProvider, leProvider)
err = Convert_V0_to_V2alpha1(tt.source, target, nil, dsProvider)
case *dashv2beta1.Dashboard:
err = Convert_V0_to_V2beta1(tt.source, target, nil, dsProvider, leProvider)
err = Convert_V0_to_V2beta1(tt.source, target, nil, dsProvider)
default:
t.Fatalf("unexpected target type: %T", target)
}
@@ -192,7 +192,7 @@ func TestV0ConversionErrorPropagation(t *testing.T) {
}
target := &dashv2beta1.Dashboard{}
err := Convert_V0_to_V2beta1(source, target, nil, dsProvider, leProvider)
err := Convert_V0_to_V2beta1(source, target, nil, dsProvider)
require.Error(t, err, "expected error to be returned on first step failure")
require.NotNil(t, target.Status.Conversion)
@@ -243,7 +243,7 @@ func TestV0ConversionSuccessPaths(t *testing.T) {
}
target := &dashv2alpha1.Dashboard{}
err := Convert_V0_to_V2alpha1(source, target, nil, dsProvider, leProvider)
err := Convert_V0_to_V2alpha1(source, target, nil, dsProvider)
require.NoError(t, err, "expected successful conversion")
// Layout should be set even on success
@@ -264,7 +264,7 @@ func TestV0ConversionSuccessPaths(t *testing.T) {
}
target := &dashv2beta1.Dashboard{}
err := Convert_V0_to_V2beta1(source, target, nil, dsProvider, leProvider)
err := Convert_V0_to_V2beta1(source, target, nil, dsProvider)
require.NoError(t, err, "expected successful conversion")
})
@@ -293,7 +293,7 @@ func TestV0ConversionSecondStepErrors(t *testing.T) {
}
target := &dashv2alpha1.Dashboard{}
err := Convert_V0_to_V2alpha1(source, target, nil, dsProvider, leProvider)
err := Convert_V0_to_V2alpha1(source, target, nil, dsProvider)
// Convert_V0_to_V2alpha1 doesn't return error, just sets status
require.NoError(t, err, "Convert_V0_to_V2alpha1 doesn't return error")
@@ -327,7 +327,7 @@ func TestV0ConversionSecondStepErrors(t *testing.T) {
}
target := &dashv2alpha1.Dashboard{}
err := Convert_V0_to_V2alpha1(source, target, nil, dsProvider, leProvider)
err := Convert_V0_to_V2alpha1(source, target, nil, dsProvider)
// Convert_V0_to_V2alpha1 doesn't return error, just sets status
require.NoError(t, err, "Convert_V0_to_V2alpha1 doesn't return error")
@@ -357,7 +357,7 @@ func TestV0ConversionSecondStepErrors(t *testing.T) {
}
target := &dashv2beta1.Dashboard{}
err := Convert_V0_to_V2beta1(source, target, nil, dsProvider, leProvider)
err := Convert_V0_to_V2beta1(source, target, nil, dsProvider)
// May or may not error depending on dashboard content
// But if it does error on second step, status should be set
@@ -383,7 +383,7 @@ func TestV0ConversionSecondStepErrors(t *testing.T) {
}
target := &dashv2beta1.Dashboard{}
err := Convert_V0_to_V2beta1(source, target, nil, dsProvider, leProvider)
err := Convert_V0_to_V2beta1(source, target, nil, dsProvider)
// May or may not error depending on dashboard content
// But if it does error on third step, status should be set

View File

@@ -25,8 +25,8 @@ func Convert_V1beta1_to_V0(in *dashv1.Dashboard, out *dashv0.Dashboard, scope co
return nil
}
func Convert_V1beta1_to_V2alpha1(in *dashv1.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope, dsIndexProvider schemaversion.DataSourceIndexProvider, leIndexProvider schemaversion.LibraryElementIndexProvider) error {
if err := ConvertDashboard_V1beta1_to_V2alpha1(in, out, scope, dsIndexProvider, leIndexProvider); err != nil {
func Convert_V1beta1_to_V2alpha1(in *dashv1.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope, dsIndexProvider schemaversion.DataSourceIndexProvider) error {
if err := ConvertDashboard_V1beta1_to_V2alpha1(in, out, scope, dsIndexProvider); err != nil {
out.Status = dashv2alpha1.DashboardStatus{
Conversion: &dashv2alpha1.DashboardConversionStatus{
StoredVersion: ptr.To(dashv1.VERSION),
@@ -60,9 +60,9 @@ func Convert_V1beta1_to_V2alpha1(in *dashv1.Dashboard, out *dashv2alpha1.Dashboa
return nil
}
func Convert_V1beta1_to_V2beta1(in *dashv1.Dashboard, out *dashv2beta1.Dashboard, scope conversion.Scope, dsIndexProvider schemaversion.DataSourceIndexProvider, leIndexProvider schemaversion.LibraryElementIndexProvider) error {
func Convert_V1beta1_to_V2beta1(in *dashv1.Dashboard, out *dashv2beta1.Dashboard, scope conversion.Scope, dsIndexProvider schemaversion.DataSourceIndexProvider) error {
v2alpha1 := &dashv2alpha1.Dashboard{}
if err := ConvertDashboard_V1beta1_to_V2alpha1(in, v2alpha1, scope, dsIndexProvider, leIndexProvider); err != nil {
if err := ConvertDashboard_V1beta1_to_V2alpha1(in, v2alpha1, scope, dsIndexProvider); err != nil {
out.Status = dashv2beta1.DashboardStatus{
Conversion: &dashv2beta1.DashboardConversionStatus{
StoredVersion: ptr.To(dashv1.VERSION),

View File

@@ -37,7 +37,7 @@ func TestV1ConversionErrorHandling(t *testing.T) {
}
target := &dashv2alpha1.Dashboard{}
err := Convert_V1beta1_to_V2alpha1(source, target, nil, dsProvider, leProvider)
err := Convert_V1beta1_to_V2alpha1(source, target, nil, dsProvider)
// Convert_V1beta1_to_V2alpha1 doesn't return error, just sets status
require.NoError(t, err, "Convert_V1beta1_to_V2alpha1 doesn't return error")
@@ -64,7 +64,7 @@ func TestV1ConversionErrorHandling(t *testing.T) {
}
target := &dashv2beta1.Dashboard{}
err := Convert_V1beta1_to_V2beta1(source, target, nil, dsProvider, leProvider)
err := Convert_V1beta1_to_V2beta1(source, target, nil, dsProvider)
// May or may not error depending on dashboard content
// But if it does error on first step, status should be set with correct StoredVersion
@@ -91,7 +91,7 @@ func TestV1ConversionErrorHandling(t *testing.T) {
}
target := &dashv2beta1.Dashboard{}
err := Convert_V1beta1_to_V2beta1(source, target, nil, dsProvider, leProvider)
err := Convert_V1beta1_to_V2beta1(source, target, nil, dsProvider)
// May or may not error depending on dashboard content
// But if it does error on second step, status should be set with correct StoredVersion
@@ -117,7 +117,7 @@ func TestV1ConversionErrorHandling(t *testing.T) {
}
target := &dashv2beta1.Dashboard{}
err := Convert_V1beta1_to_V2beta1(source, target, nil, dsProvider, leProvider)
err := Convert_V1beta1_to_V2beta1(source, target, nil, dsProvider)
// Should succeed if dashboard is valid
if err == nil {

View File

@@ -80,7 +80,7 @@ func prepareV1beta1ConversionContext(in *dashv1.Dashboard, dsIndexProvider schem
return ctx, &nsInfo, nil
}
func ConvertDashboard_V1beta1_to_V2alpha1(in *dashv1.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope, dsIndexProvider schemaversion.DataSourceIndexProvider, leIndexProvider schemaversion.LibraryElementIndexProvider) error {
func ConvertDashboard_V1beta1_to_V2alpha1(in *dashv1.Dashboard, out *dashv2alpha1.Dashboard, scope conversion.Scope, dsIndexProvider schemaversion.DataSourceIndexProvider) error {
out.ObjectMeta = in.ObjectMeta
out.APIVersion = dashv2alpha1.APIVERSION
out.Kind = in.Kind
@@ -94,10 +94,10 @@ func ConvertDashboard_V1beta1_to_V2alpha1(in *dashv1.Dashboard, out *dashv2alpha
return fmt.Errorf("failed to prepare conversion context: %w", err)
}
return convertDashboardSpec_V1beta1_to_V2alpha1(&in.Spec, &out.Spec, scope, ctx, dsIndexProvider, leIndexProvider)
return convertDashboardSpec_V1beta1_to_V2alpha1(&in.Spec, &out.Spec, scope, ctx, dsIndexProvider)
}
func convertDashboardSpec_V1beta1_to_V2alpha1(in *dashv1.DashboardSpec, out *dashv2alpha1.DashboardSpec, scope conversion.Scope, ctx context.Context, dsIndexProvider schemaversion.DataSourceIndexProvider, leIndexProvider schemaversion.LibraryElementIndexProvider) error {
func convertDashboardSpec_V1beta1_to_V2alpha1(in *dashv1.DashboardSpec, out *dashv2alpha1.DashboardSpec, scope conversion.Scope, ctx context.Context, dsIndexProvider schemaversion.DataSourceIndexProvider) error {
// Parse the unstructured spec into a dashboard JSON structure
dashboardJSON, ok := in.Object["dashboard"]
if !ok {
@@ -161,7 +161,7 @@ func convertDashboardSpec_V1beta1_to_V2alpha1(in *dashv1.DashboardSpec, out *das
out.Links = transformLinks(dashboard)
// Transform panels to elements and layout
elements, layout, err := transformPanelsToElementsAndLayout(ctx, dashboard, dsIndexProvider, leIndexProvider)
elements, layout, err := transformPanelsToElementsAndLayout(ctx, dashboard, dsIndexProvider)
if err != nil {
return fmt.Errorf("failed to transform panels: %w", err)
}
@@ -387,7 +387,7 @@ func transformLinks(dashboard map[string]interface{}) []dashv2alpha1.DashboardDa
// Panel transformation constants
const GRID_ROW_HEIGHT = 1
func transformPanelsToElementsAndLayout(ctx context.Context, dashboard map[string]interface{}, dsIndexProvider schemaversion.DataSourceIndexProvider, leIndexProvider schemaversion.LibraryElementIndexProvider) (map[string]dashv2alpha1.DashboardElement, dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind, error) {
func transformPanelsToElementsAndLayout(ctx context.Context, dashboard map[string]interface{}, dsIndexProvider schemaversion.DataSourceIndexProvider) (map[string]dashv2alpha1.DashboardElement, dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind, error) {
panels, ok := dashboard["panels"].([]interface{})
if !ok {
// Return empty elements and default grid layout
@@ -415,13 +415,13 @@ func transformPanelsToElementsAndLayout(ctx context.Context, dashboard map[strin
}
if hasRowPanels {
return convertToRowsLayout(ctx, panels, dsIndexProvider, leIndexProvider)
return convertToRowsLayout(ctx, panels, dsIndexProvider)
}
return convertToGridLayout(ctx, panels, dsIndexProvider, leIndexProvider)
return convertToGridLayout(ctx, panels, dsIndexProvider)
}
func convertToGridLayout(ctx context.Context, panels []interface{}, dsIndexProvider schemaversion.DataSourceIndexProvider, leIndexProvider schemaversion.LibraryElementIndexProvider) (map[string]dashv2alpha1.DashboardElement, dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind, error) {
func convertToGridLayout(ctx context.Context, panels []interface{}, dsIndexProvider schemaversion.DataSourceIndexProvider) (map[string]dashv2alpha1.DashboardElement, dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind, error) {
elements := make(map[string]dashv2alpha1.DashboardElement)
items := make([]dashv2alpha1.DashboardGridLayoutItemKind, 0, len(panels))
@@ -437,7 +437,7 @@ func convertToGridLayout(ctx context.Context, panels []interface{}, dsIndexProvi
}
elements[elementName] = element
items = append(items, buildGridItemKind(ctx, panelMap, elementName, nil, leIndexProvider))
items = append(items, buildGridItemKind(panelMap, elementName, nil))
}
layout := dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind{
@@ -452,7 +452,7 @@ func convertToGridLayout(ctx context.Context, panels []interface{}, dsIndexProvi
return elements, layout, nil
}
func convertToRowsLayout(ctx context.Context, panels []interface{}, dsIndexProvider schemaversion.DataSourceIndexProvider, leIndexProvider schemaversion.LibraryElementIndexProvider) (map[string]dashv2alpha1.DashboardElement, dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind, error) {
func convertToRowsLayout(ctx context.Context, panels []interface{}, dsIndexProvider schemaversion.DataSourceIndexProvider) (map[string]dashv2alpha1.DashboardElement, dashv2alpha1.DashboardGridLayoutKindOrRowsLayoutKindOrAutoGridLayoutKindOrTabsLayoutKind, error) {
elements := make(map[string]dashv2alpha1.DashboardElement)
rows := make([]dashv2alpha1.DashboardRowsLayoutRowKind, 0)
@@ -491,7 +491,7 @@ func convertToRowsLayout(ctx context.Context, panels []interface{}, dsIndexProvi
element, name, err := buildElement(ctx, collapsedPanelMap, dsIndexProvider)
if err == nil {
elements[name] = element
rowElements = append(rowElements, buildGridItemKind(ctx, collapsedPanelMap, name, int64Ptr(yOffsetInRows(collapsedPanelMap, legacyRowY)), leIndexProvider))
rowElements = append(rowElements, buildGridItemKind(collapsedPanelMap, name, int64Ptr(yOffsetInRows(collapsedPanelMap, legacyRowY))))
}
}
}
@@ -512,7 +512,7 @@ func convertToRowsLayout(ctx context.Context, panels []interface{}, dsIndexProvi
if currentRow.Spec.Layout.GridLayoutKind != nil {
currentRow.Spec.Layout.GridLayoutKind.Spec.Items = append(
currentRow.Spec.Layout.GridLayoutKind.Spec.Items,
buildGridItemKind(ctx, panelMap, elementName, int64Ptr(yOffsetInRows(panelMap, legacyRowY)), leIndexProvider),
buildGridItemKind(panelMap, elementName, int64Ptr(yOffsetInRows(panelMap, legacyRowY))),
)
}
} else {
@@ -521,7 +521,7 @@ func convertToRowsLayout(ctx context.Context, panels []interface{}, dsIndexProvi
// The Y position does not matter for the rows layout, but it's used to calculate the position of the panels in the grid layout in the row.
legacyRowY = -1
gridItems := []dashv2alpha1.DashboardGridLayoutItemKind{
buildGridItemKind(ctx, panelMap, elementName, int64Ptr(0), leIndexProvider),
buildGridItemKind(panelMap, elementName, int64Ptr(0)),
}
hideHeader := true
@@ -645,7 +645,7 @@ func buildPanelKind(ctx context.Context, panelMap map[string]interface{}, dsInde
return panelKind, nil
}
func buildGridItemKind(ctx context.Context, panelMap map[string]interface{}, elementName string, yOverride *int64, leIndexProvider schemaversion.LibraryElementIndexProvider) dashv2alpha1.DashboardGridLayoutItemKind {
func buildGridItemKind(panelMap map[string]interface{}, elementName string, yOverride *int64) dashv2alpha1.DashboardGridLayoutItemKind {
// Default grid position (matches frontend PanelModel defaults: w=6, h=3)
x, y, width, height := int64(0), int64(0), int64(6), int64(3)
@@ -677,78 +677,34 @@ func buildGridItemKind(ctx context.Context, panelMap map[string]interface{}, ele
}
// Handle repeat options
// First check if repeat options are set on the panel itself (dashboard instance level)
repeatOptions := getRepeatOptionsFromPanel(panelMap)
if repeat := schemaversion.GetStringValue(panelMap, "repeat"); repeat != "" {
repeatOptions := &dashv2alpha1.DashboardRepeatOptions{
Mode: "variable",
Value: repeat,
}
// If no repeat options on the panel and it's a library panel, try to get them from the library panel definition
if repeatOptions == nil {
if libraryPanel, ok := panelMap["libraryPanel"].(map[string]interface{}); ok {
libraryPanelUID := schemaversion.GetStringValue(libraryPanel, "uid")
if libraryPanelUID != "" && leIndexProvider != nil {
repeatOptions = getRepeatOptionsFromLibraryPanel(ctx, libraryPanelUID, leIndexProvider)
if repeatDirection := schemaversion.GetStringValue(panelMap, "repeatDirection"); repeatDirection != "" {
switch repeatDirection {
case "h":
direction := dashv2alpha1.DashboardRepeatOptionsDirectionH
repeatOptions.Direction = &direction
case "v":
direction := dashv2alpha1.DashboardRepeatOptionsDirectionV
repeatOptions.Direction = &direction
}
}
}
if repeatOptions != nil {
if maxPerRow := getIntField(panelMap, "maxPerRow", 0); maxPerRow > 0 {
maxPerRowInt64 := int64(maxPerRow)
repeatOptions.MaxPerRow = &maxPerRowInt64
}
item.Spec.Repeat = repeatOptions
}
return item
}
// getRepeatOptionsFromPanel extracts repeat options from a panel map (dashboard instance level)
func getRepeatOptionsFromPanel(panelMap map[string]any) *dashv2alpha1.DashboardRepeatOptions {
repeat := schemaversion.GetStringValue(panelMap, "repeat")
if repeat == "" {
return nil
}
repeatOptions := &dashv2alpha1.DashboardRepeatOptions{
Mode: "variable",
Value: repeat,
}
if repeatDirection := schemaversion.GetStringValue(panelMap, "repeatDirection"); repeatDirection != "" {
switch repeatDirection {
case "h":
direction := dashv2alpha1.DashboardRepeatOptionsDirectionH
repeatOptions.Direction = &direction
case "v":
direction := dashv2alpha1.DashboardRepeatOptionsDirectionV
repeatOptions.Direction = &direction
}
}
if maxPerRow := getIntField(panelMap, "maxPerRow", 0); maxPerRow > 0 {
maxPerRowInt64 := int64(maxPerRow)
repeatOptions.MaxPerRow = &maxPerRowInt64
}
return repeatOptions
}
// getRepeatOptionsFromLibraryPanel retrieves repeat options from a library panel by UID
func getRepeatOptionsFromLibraryPanel(ctx context.Context, libraryPanelUID string, leIndexProvider schemaversion.LibraryElementIndexProvider) *dashv2alpha1.DashboardRepeatOptions {
libraryElements := leIndexProvider.GetLibraryElementInfo(ctx)
// Find the library panel by UID
var libraryPanelModel map[string]any
for _, elem := range libraryElements {
if elem.UID == libraryPanelUID {
libraryPanelModel = elem.Model.Object
break
}
}
if libraryPanelModel == nil {
return nil
}
// Extract repeat options from the library panel model
return getRepeatOptionsFromPanel(libraryPanelModel)
}
func buildRowKind(rowPanelMap map[string]interface{}, elements []dashv2alpha1.DashboardGridLayoutItemKind) *dashv2alpha1.DashboardRowsLayoutRowKind {
collapsed := getBoolField(rowPanelMap, "collapsed", false)
title := schemaversion.GetStringValue(rowPanelMap, "title")

View File

@@ -216,60 +216,3 @@ func MigrateDatasourceNameToRef(nameOrRef interface{}, options map[string]bool,
return nil
}
// cachedLibraryElementProvider wraps a LibraryElementIndexProvider with time-based caching.
// This prevents multiple DB queries during operations that may call GetLibraryElementInfo()
// multiple times (e.g., dashboard conversions with many library panel lookups).
// The cache expires after 10 seconds, allowing it to be used as a long-lived singleton
// while still refreshing periodically.
//
// Thread-safe: Uses sync.RWMutex to guarantee safe concurrent access.
type cachedLibraryElementProvider struct {
provider LibraryElementIndexProvider
mu sync.RWMutex
elements []LibraryElementInfo
cachedAt time.Time
cacheTTL time.Duration
}
// GetLibraryElementInfo returns the cached library elements if they're still valid (< 10s old), otherwise rebuilds the cache.
// Uses RWMutex for efficient concurrent reads when cache is valid.
func (p *cachedLibraryElementProvider) GetLibraryElementInfo(ctx context.Context) []LibraryElementInfo {
// Fast path: check if cache is still valid using read lock
p.mu.RLock()
if p.elements != nil && time.Since(p.cachedAt) < p.cacheTTL {
elements := p.elements
p.mu.RUnlock()
return elements
}
p.mu.RUnlock()
// Slow path: cache expired or not yet built, acquire write lock
p.mu.Lock()
defer p.mu.Unlock()
// Double-check: another goroutine might have refreshed the cache
// while we were waiting for the write lock
if p.elements != nil && time.Since(p.cachedAt) < p.cacheTTL {
return p.elements
}
// Rebuild the cache
p.elements = p.provider.GetLibraryElementInfo(ctx)
p.cachedAt = time.Now()
return p.elements
}
// WrapLibraryElementProviderWithCache wraps a provider to cache library elements with a 10-second TTL.
// Useful for conversions or migrations that may call GetLibraryElementInfo() multiple times.
// The cache expires after 10 seconds, making it suitable for use as a long-lived singleton
// at the top level of dependency injection while still refreshing periodically.
func WrapLibraryElementProviderWithCache(provider LibraryElementIndexProvider) LibraryElementIndexProvider {
if provider == nil {
return nil
}
return &cachedLibraryElementProvider{
provider: provider,
cacheTTL: 10 * time.Second,
}
}

View File

@@ -3,8 +3,6 @@ package schemaversion
import (
"context"
"strconv"
common "github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
)
const (
@@ -36,7 +34,6 @@ type LibraryElementInfo struct {
Type string
Description string
FolderUID string
Model common.Unstructured // JSON model of the library element, used to extract repeat options during migration
}
type LibraryElementIndexProvider interface {

View File

@@ -4,7 +4,6 @@ import (
"context"
"github.com/grafana/grafana/apps/dashboard/pkg/migration/schemaversion"
"github.com/grafana/grafana/pkg/apimachinery/apis/common/v0alpha1"
)
// EmptyLibraryElementProvider provides an empty library element list for tests
@@ -188,101 +187,3 @@ func (p *ConfigurableDataSourceProvider) getDevDashboardDataSources() []schemave
},
}
}
// TestLibraryElementProvider provides library elements with models for testing repeat options migration
type TestLibraryElementProvider struct {
elements []schemaversion.LibraryElementInfo
}
// NewTestLibraryElementProvider creates a new test library element provider with sample library panels
func NewTestLibraryElementProvider() *TestLibraryElementProvider {
// Create library panel models with repeat options
libPanelWithRepeatH := map[string]any{
"id": 1,
"type": "timeseries",
"title": "Library Panel with Horizontal Repeat",
"repeat": "server",
"repeatDirection": "h",
"maxPerRow": 3,
"gridPos": map[string]any{
"x": 0,
"y": 0,
"w": 12,
"h": 8,
},
"targets": []any{},
"options": map[string]any{},
}
libPanelWithRepeatV := map[string]any{
"id": 2,
"type": "stat",
"title": "Library Panel with Vertical Repeat",
"repeat": "datacenter",
"repeatDirection": "v",
"gridPos": map[string]any{
"x": 0,
"y": 0,
"w": 6,
"h": 4,
},
"targets": []any{},
"options": map[string]any{},
}
libPanelWithoutRepeat := map[string]any{
"id": 3,
"type": "text",
"title": "Library Panel without Repeat",
"gridPos": map[string]any{
"x": 0,
"y": 0,
"w": 6,
"h": 3,
},
"targets": []any{},
"options": map[string]any{},
}
// Convert models to Unstructured
modelWithRepeatH := v0alpha1.Unstructured{Object: libPanelWithRepeatH}
modelWithRepeatV := v0alpha1.Unstructured{Object: libPanelWithRepeatV}
modelWithoutRepeat := v0alpha1.Unstructured{Object: libPanelWithoutRepeat}
return &TestLibraryElementProvider{
elements: []schemaversion.LibraryElementInfo{
{
UID: "lib-panel-repeat-h",
Name: "Library Panel with Horizontal Repeat",
Kind: 1, // Panel element
Type: "timeseries",
Description: "A library panel with horizontal repeat options",
FolderUID: "",
Model: modelWithRepeatH,
},
{
UID: "lib-panel-repeat-v",
Name: "Library Panel with Vertical Repeat",
Kind: 1, // Panel element
Type: "stat",
Description: "A library panel with vertical repeat options",
FolderUID: "",
Model: modelWithRepeatV,
},
{
UID: "lib-panel-no-repeat",
Name: "Library Panel without Repeat",
Kind: 1, // Panel element
Type: "text",
Description: "A library panel without repeat options",
FolderUID: "",
Model: modelWithoutRepeat,
},
},
}
}
// GetLibraryElementInfo returns the test library elements
func (p *TestLibraryElementProvider) GetLibraryElementInfo(_ context.Context) []schemaversion.LibraryElementInfo {
return p.elements
}

View File

@@ -35,7 +35,7 @@ require (
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f // indirect
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4 // indirect
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37 // indirect
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
@@ -56,7 +56,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/puzpuzpuz/xsync/v2 v2.5.1 // indirect
github.com/spf13/pflag v1.0.10 // indirect

View File

@@ -52,8 +52,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f h1:Cbm6OKkOcJ+7CSZsGsEJzktC/SIa5bxVeYKQLuYK86o=
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f/go.mod h1:axY0cdOg3q0TZHwpHnIz5x16xZ8ZBxJHShsSHHXcHQg=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4 h1:Muoy+FMGrHj3GdFbvsMzUT7eusgii9PKf9L1ZaXDDbY=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37 h1:qEwZ+7MbPjzRvTi31iT9w7NBhKIpKwZrFbYmOZLqkwA=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4 h1:jSojuc7njleS3UOz223WDlXOinmuLAIPI0z2vtq8EgI=
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4/go.mod h1:VahT+GtfQIM+o8ht2StR6J9g+Ef+C2Vokh5uuSmOD/4=
github.com/grafana/grafana-app-sdk v0.48.2 h1:CQQDhwo1fWaXQVKvxxOcK6azbuY3E2TgJHNAZlYYn7U=
@@ -116,8 +116,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU=

View File

@@ -40,7 +40,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.11.1 // indirect

View File

@@ -85,8 +85,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=

View File

@@ -46,7 +46,7 @@ replace github.com/prometheus/alertmanager => github.com/grafana/prometheus-aler
require (
github.com/grafana/grafana v0.0.0-00010101000000-000000000000
github.com/grafana/grafana-app-sdk v0.48.2
github.com/grafana/grafana-app-sdk v0.48.1
github.com/grafana/grafana-app-sdk/logging v0.48.1
github.com/grafana/grafana/apps/folder v0.0.0
github.com/grafana/grafana/pkg/apimachinery v0.0.0
@@ -231,12 +231,12 @@ require (
github.com/gorilla/mux v1.8.1 // indirect
github.com/grafana/alerting v0.0.0-20251009192429-9427c24835ae // indirect
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f // indirect
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4 // indirect
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37 // indirect
github.com/grafana/dataplane/sdata v0.0.9 // indirect
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4 // indirect
github.com/grafana/grafana-aws-sdk v1.3.0 // indirect
github.com/grafana/grafana-azure-sdk-go/v2 v2.3.1 // indirect
github.com/grafana/grafana-plugin-sdk-go v0.283.0 // indirect
github.com/grafana/grafana-plugin-sdk-go v0.281.0 // indirect
github.com/grafana/grafana/apps/dashboard v0.0.0 // indirect
github.com/grafana/grafana/apps/plugins v0.0.0 // indirect
github.com/grafana/grafana/apps/provisioning v0.0.0 // indirect
@@ -251,7 +251,7 @@ require (
github.com/grafana/sqlds/v4 v4.2.7 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.1.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.1-0.20191002090509-6af20e3a5340 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
github.com/hashicorp/consul/api v1.31.2 // indirect
@@ -349,7 +349,7 @@ require (
github.com/pressly/goose/v3 v3.25.0 // indirect
github.com/prometheus/alertmanager v0.28.0 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/common v0.67.1 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
github.com/prometheus/exporter-toolkit v0.14.0 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
@@ -425,18 +425,18 @@ require (
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
gocloud.dev v0.43.0 // indirect
golang.org/x/crypto v0.44.0 // indirect
golang.org/x/crypto v0.43.0 // indirect
golang.org/x/exp v0.0.0-20251002181428-27f1f14c8bb9 // indirect
golang.org/x/mod v0.30.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/oauth2 v0.33.0 // indirect
golang.org/x/sync v0.18.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/telemetry v0.0.0-20251111182119-bc8e575c7b54 // indirect
golang.org/x/term v0.37.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/mod v0.29.0 // indirect
golang.org/x/net v0.46.0 // indirect
golang.org/x/oauth2 v0.32.0 // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/sys v0.37.0 // indirect
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8 // indirect
golang.org/x/term v0.36.0 // indirect
golang.org/x/text v0.30.0 // indirect
golang.org/x/time v0.14.0 // indirect
golang.org/x/tools v0.39.0 // indirect
golang.org/x/tools v0.38.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
gonum.org/v1/gonum v0.16.0 // indirect

View File

@@ -839,8 +839,6 @@ github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f h1:Cbm6OKkOcJ+7CSZ
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f/go.mod h1:axY0cdOg3q0TZHwpHnIz5x16xZ8ZBxJHShsSHHXcHQg=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37 h1:qEwZ+7MbPjzRvTi31iT9w7NBhKIpKwZrFbYmOZLqkwA=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4 h1:Muoy+FMGrHj3GdFbvsMzUT7eusgii9PKf9L1ZaXDDbY=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/dataplane/examples v0.0.1 h1:K9M5glueWyLoL4//H+EtTQq16lXuHLmOhb6DjSCahzA=
github.com/grafana/dataplane/examples v0.0.1/go.mod h1:h5YwY8s407/17XF5/dS8XrUtsTVV2RnuW8+m1Mp46mg=
github.com/grafana/dataplane/sdata v0.0.9 h1:AGL1LZnCUG4MnQtnWpBPbQ8ZpptaZs14w6kE/MWfg7s=
@@ -855,7 +853,6 @@ github.com/grafana/gomemcache v0.0.0-20250828162811-a96f6acee2fe h1:q+QaVANzNZxv
github.com/grafana/gomemcache v0.0.0-20250828162811-a96f6acee2fe/go.mod h1:j/s0jkda4UXTemDs7Pgw/vMT06alWc42CHisvYac0qw=
github.com/grafana/grafana-app-sdk v0.48.1 h1:bKJadWH18WCpJ+Zk8AezRFXCcZgGredRv+fRS+8zkek=
github.com/grafana/grafana-app-sdk v0.48.1/go.mod h1:5LljCz+wvmGfkQ8ZKTOfserhtXNEF0cSFthoWShvN6c=
github.com/grafana/grafana-app-sdk v0.48.2/go.mod h1:LDOvQ7OOyHLcXdSa0InATCa5OMoYAd6E1+rGLrMgHuk=
github.com/grafana/grafana-app-sdk/logging v0.48.1 h1:veM0X5LAPyN3KsDLglWjIofndbGuf7MqnrDuDN+F/Ng=
github.com/grafana/grafana-app-sdk/logging v0.48.1/go.mod h1:Gh/nBWnspK3oDNWtiM5qUF/fardHzOIEez+SPI3JeHA=
github.com/grafana/grafana-aws-sdk v1.3.0 h1:/bfJzP93rCel1GbWoRSq0oUo424MZXt8jAp2BK9w8tM=
@@ -870,7 +867,6 @@ github.com/grafana/grafana-openapi-client-go v0.0.0-20231213163343-bd475d63fb79
github.com/grafana/grafana-openapi-client-go v0.0.0-20231213163343-bd475d63fb79/go.mod h1:wc6Hbh3K2TgCUSfBC/BOzabItujtHMESZeFk5ZhdxhQ=
github.com/grafana/grafana-plugin-sdk-go v0.281.0 h1:V8dGyatzcOLQeivFhBV2JWMwTSZH/clDnpfKG9p3dTA=
github.com/grafana/grafana-plugin-sdk-go v0.281.0/go.mod h1:3I0g+v6jAwVmrt6BEjDUP4V6pkhGP5QKY5NkXY4Ayr4=
github.com/grafana/grafana-plugin-sdk-go v0.283.0/go.mod h1:20qhoYxIgbZRmwCEO1KMP8q2yq/Kge5+xE/99/hLEk0=
github.com/grafana/grafana/apps/example v0.0.0-20251027162426-edef69fdc82b h1:6Bo65etvjQ4tStkaA5+N3A3ENbO4UAWj53TxF6g2Hdk=
github.com/grafana/grafana/apps/example v0.0.0-20251027162426-edef69fdc82b/go.mod h1:6+wASOCN8LWt6FJ8dc0oODUBIEY5XHaE6ABi8g0mR+k=
github.com/grafana/grafana/pkg/promlib v0.0.8 h1:VUWsqttdf0wMI4j9OX9oNrykguQpZcruudDAFpJJVw0=
@@ -905,7 +901,6 @@ github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.1.0 h1:QGLs
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.1.0/go.mod h1:hM2alZsMUni80N33RBe6J0e423LB+odMj7d3EMP9l20=
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2 h1:sGm2vDRFUrQJO/Veii4h4zG2vvqG6uWNkBHSTqXOZk0=
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2/go.mod h1:wd1YpapPLivG6nQgbf7ZkG1hhSOXDhhn4MLTknx2aAc=
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3/go.mod h1:NbCUVmiS4foBGBHOYlCT25+YmGpJ32dZPi75pGEUpj4=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.1-0.20191002090509-6af20e3a5340 h1:uGoIog/wiQHI9GAxXO5TJbT0wWKH3O9HhOJW1F9c3fY=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.1-0.20191002090509-6af20e3a5340/go.mod h1:3bDW6wMZJB7tiONtC/1Xpicra6Wp5GgbTbQWCbI5fkc=
@@ -1379,7 +1374,6 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9
github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
github.com/prometheus/common v0.67.1 h1:OTSON1P4DNxzTg4hmKCc37o4ZAZDv0cfXLkOt0oEowI=
github.com/prometheus/common v0.67.1/go.mod h1:RpmT9v35q2Y+lsieQsdOh5sXZ6ajUGC8NjZAmr8vb0Q=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4=
github.com/prometheus/common/sigv4 v0.1.0/go.mod h1:2Jkxxk9yYvCkE5G1sQT7GuEXm57JrvHu9k5YwTjsNtI=
github.com/prometheus/exporter-toolkit v0.14.0 h1:NMlswfibpcZZ+H0sZBiTjrA3/aBFHkNZqE+iCj5EmRg=
@@ -1736,7 +1730,6 @@ golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@@ -1780,7 +1773,6 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -1837,7 +1829,6 @@ golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1862,7 +1853,6 @@ golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
golang.org/x/oauth2 v0.32.0 h1:jsCblLleRMDrxMN29H3z/k1KliIvpLgCkE6R8FXXNgY=
golang.org/x/oauth2 v0.32.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
golang.org/x/oauth2 v0.33.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
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=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -1877,7 +1867,6 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -1972,15 +1961,12 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8 h1:LvzTn0GQhWuvKH/kVRS3R3bVAsdQWI7hvfLHGgh9+lU=
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8/go.mod h1:Pi4ztBfryZoJEkyFTI5/Ocsu2jXyDr6iSdgJiYE/uwE=
golang.org/x/telemetry v0.0.0-20251111182119-bc8e575c7b54/go.mod h1:hKdjCMrbv9skySur+Nek8Hd0uJ0GuxJIoIX2payrIdQ=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q=
golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss=
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
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=
@@ -1992,7 +1978,6 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -2061,7 +2046,6 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=
golang.org/x/tools/godoc v0.1.0-deprecated h1:o+aZ1BOj6Hsx/GBdJO/s815sqftjSnrZZwyYTHODvtk=
golang.org/x/tools/godoc v0.1.0-deprecated/go.mod h1:qM63CriJ961IHWmnWa9CjZnBndniPt4a3CK0PVB9bIg=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -2321,27 +2305,20 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.34.1 h1:jC+153630BMdlFukegoEL8E/yT7aLyQkIVuwhmwDgJM=
k8s.io/api v0.34.1/go.mod h1:SB80FxFtXn5/gwzCoN6QCtPD7Vbu5w2n1S0J5gFfTYk=
k8s.io/api v0.34.2/go.mod h1:MMBPaWlED2a8w4RSeanD76f7opUoypY8TFYkSM+3XHw=
k8s.io/apiextensions-apiserver v0.34.1 h1:NNPBva8FNAPt1iSVwIE0FsdrVriRXMsaWFMqJbII2CI=
k8s.io/apiextensions-apiserver v0.34.1/go.mod h1:hP9Rld3zF5Ay2Of3BeEpLAToP+l4s5UlxiHfqRaRcMc=
k8s.io/apiextensions-apiserver v0.34.2/go.mod h1:398CJrsgXF1wytdaanynDpJ67zG4Xq7yj91GrmYN2SE=
k8s.io/apimachinery v0.34.1 h1:dTlxFls/eikpJxmAC7MVE8oOeP1zryV7iRyIjB0gky4=
k8s.io/apimachinery v0.34.1/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
k8s.io/apimachinery v0.34.2/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
k8s.io/apiserver v0.34.1 h1:U3JBGdgANK3dfFcyknWde1G6X1F4bg7PXuvlqt8lITA=
k8s.io/apiserver v0.34.1/go.mod h1:eOOc9nrVqlBI1AFCvVzsob0OxtPZUCPiUJL45JOTBG0=
k8s.io/apiserver v0.34.2/go.mod h1:gqJQy2yDOB50R3JUReHSFr+cwJnL8G1dzTA0YLEqAPI=
k8s.io/client-go v0.34.1 h1:ZUPJKgXsnKwVwmKKdPfw4tB58+7/Ik3CrjOEhsiZ7mY=
k8s.io/client-go v0.34.1/go.mod h1:kA8v0FP+tk6sZA0yKLRG67LWjqufAoSHA2xVGKw9Of8=
k8s.io/client-go v0.34.2/go.mod h1:2VYDl1XXJsdcAxw7BenFslRQX28Dxz91U9MWKjX97fE=
k8s.io/component-base v0.34.1 h1:v7xFgG+ONhytZNFpIz5/kecwD+sUhVE6HU7qQUiRM4A=
k8s.io/component-base v0.34.1/go.mod h1:mknCpLlTSKHzAQJJnnHVKqjxR7gBeHRv0rPXA7gdtQ0=
k8s.io/component-base v0.34.2/go.mod h1:9xw2FHJavUHBFpiGkZoKuYZ5pdtLKe97DEByaA+hHbM=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kms v0.34.1 h1:iCFOvewDPzWM9fMTfyIPO+4MeuZ0tcZbugxLNSHFG4w=
k8s.io/kms v0.34.1/go.mod h1:s1CFkLG7w9eaTYvctOxosx88fl4spqmixnNpys0JAtM=
k8s.io/kms v0.34.2/go.mod h1:s1CFkLG7w9eaTYvctOxosx88fl4spqmixnNpys0JAtM=
k8s.io/kube-aggregator v0.34.1 h1:WNLV0dVNoFKmuyvdWLd92iDSyD/TSTjqwaPj0U9XAEU=
k8s.io/kube-aggregator v0.34.1/go.mod h1:RU8j+5ERfp0h+gIvWtxRPfsa5nK7rboDm8RST8BJfYQ=
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 h1:Y3gxNAuB0OBLImH611+UDZcmKS3g6CthxToOb37KgwE=

View File

@@ -50,7 +50,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/puzpuzpuz/xsync/v2 v2.5.1 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect

View File

@@ -104,8 +104,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU=

View File

@@ -51,7 +51,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/puzpuzpuz/xsync/v2 v2.5.1 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect

View File

@@ -104,8 +104,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU=

View File

@@ -51,7 +51,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/puzpuzpuz/xsync/v2 v2.5.1 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect

View File

@@ -104,8 +104,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU=

View File

@@ -37,7 +37,7 @@ require (
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f // indirect
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4 // indirect
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37 // indirect
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
@@ -58,7 +58,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/puzpuzpuz/xsync/v2 v2.5.1 // indirect
github.com/spf13/pflag v1.0.10 // indirect

View File

@@ -52,8 +52,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f h1:Cbm6OKkOcJ+7CSZsGsEJzktC/SIa5bxVeYKQLuYK86o=
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f/go.mod h1:axY0cdOg3q0TZHwpHnIz5x16xZ8ZBxJHShsSHHXcHQg=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4 h1:Muoy+FMGrHj3GdFbvsMzUT7eusgii9PKf9L1ZaXDDbY=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37 h1:qEwZ+7MbPjzRvTi31iT9w7NBhKIpKwZrFbYmOZLqkwA=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4 h1:jSojuc7njleS3UOz223WDlXOinmuLAIPI0z2vtq8EgI=
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4/go.mod h1:VahT+GtfQIM+o8ht2StR6J9g+Ef+C2Vokh5uuSmOD/4=
github.com/grafana/grafana-app-sdk v0.48.2 h1:CQQDhwo1fWaXQVKvxxOcK6azbuY3E2TgJHNAZlYYn7U=
@@ -116,8 +116,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU=

View File

@@ -13,7 +13,7 @@ pluginV0Alpha1: {
id: string
version: string
url?: string
class: "core" | "external"
class: "core" | "external" | "cdn"
}
}
routes: {
@@ -233,4 +233,4 @@ pluginV0Alpha1: {
title?: string
description?: string
}]
}
}

View File

@@ -21,4 +21,5 @@ type PluginSpecClass string
const (
PluginSpecClassCore PluginSpecClass = "core"
PluginSpecClassExternal PluginSpecClass = "external"
PluginSpecClassCdn PluginSpecClass = "cdn"
)

File diff suppressed because one or more lines are too long

View File

@@ -23,6 +23,7 @@ type Class = string
const (
ClassCore Class = "core"
ClassExternal Class = "external"
ClassCDN Class = "cdn"
)
type Source = string

View File

@@ -446,6 +446,19 @@ func TestPluginInstall_ToPluginInstallV0Alpha1(t *testing.T) {
require.Equal(t, pluginsv0alpha1.PluginSpecClass(ClassCore), p.Spec.Class)
},
},
{
name: "cdn class is mapped correctly",
install: PluginInstall{
ID: "plugin-cdn",
Version: "3.0.0",
Class: ClassCDN,
Source: SourcePluginStore,
},
namespace: "org-3",
validate: func(t *testing.T, p *pluginsv0alpha1.Plugin) {
require.Equal(t, pluginsv0alpha1.PluginSpecClass(ClassCDN), p.Spec.Class)
},
},
{
name: "source annotation is set correctly",
install: PluginInstall{

View File

@@ -40,7 +40,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/stretchr/testify v1.11.1 // indirect

View File

@@ -85,8 +85,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=

View File

@@ -10,7 +10,7 @@ require (
github.com/grafana/grafana-app-sdk/logging v0.48.1
github.com/grafana/grafana/apps/secret v0.0.0-20250902093454-b56b7add012f
github.com/grafana/grafana/pkg/apimachinery v0.0.0-20250804150913-990f1c69ecc2
github.com/grafana/nanogit v0.3.0
github.com/grafana/nanogit v0.0.0-20251106115617-c622d3e0fc4b
github.com/migueleliasweb/go-github-mock v1.1.0
github.com/stretchr/testify v1.11.1
golang.org/x/oauth2 v0.33.0
@@ -42,7 +42,7 @@ require (
github.com/google/go-github/v64 v64.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4 // indirect
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37 // indirect
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4 // indirect
github.com/grafana/grafana-app-sdk v0.48.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
@@ -57,7 +57,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/stretchr/objx v0.5.2 // indirect

View File

@@ -58,8 +58,8 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f h1:Cbm6OKkOcJ+7CSZsGsEJzktC/SIa5bxVeYKQLuYK86o=
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f/go.mod h1:axY0cdOg3q0TZHwpHnIz5x16xZ8ZBxJHShsSHHXcHQg=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4 h1:Muoy+FMGrHj3GdFbvsMzUT7eusgii9PKf9L1ZaXDDbY=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37 h1:qEwZ+7MbPjzRvTi31iT9w7NBhKIpKwZrFbYmOZLqkwA=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4 h1:jSojuc7njleS3UOz223WDlXOinmuLAIPI0z2vtq8EgI=
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4/go.mod h1:VahT+GtfQIM+o8ht2StR6J9g+Ef+C2Vokh5uuSmOD/4=
github.com/grafana/grafana-app-sdk v0.48.2 h1:CQQDhwo1fWaXQVKvxxOcK6azbuY3E2TgJHNAZlYYn7U=
@@ -70,8 +70,8 @@ github.com/grafana/grafana/apps/secret v0.0.0-20250902093454-b56b7add012f h1:f+Z
github.com/grafana/grafana/apps/secret v0.0.0-20250902093454-b56b7add012f/go.mod h1:RA8mP8KVIwKXBx3Ssqa/uEBABib5LvUWYPVMxrNvnP0=
github.com/grafana/grafana/pkg/apimachinery v0.0.0-20250804150913-990f1c69ecc2 h1:X0cnaFdR+iz+sDSuoZmkryFSjOirchHe2MdKSRwBWgM=
github.com/grafana/grafana/pkg/apimachinery v0.0.0-20250804150913-990f1c69ecc2/go.mod h1:RRvSjHH12/PnQaXraMO65jUhVu8n59mzvhfIMBETnV4=
github.com/grafana/nanogit v0.3.0 h1:XNEef+4Vi+465ZITJs/g/xgnDRJbWhhJ7iQrAnWZ0oQ=
github.com/grafana/nanogit v0.3.0/go.mod h1:6s6CCTpyMOHPpcUZaLGI+rgBEKdmxVbhqSGgCK13j7Y=
github.com/grafana/nanogit v0.0.0-20251106115617-c622d3e0fc4b h1:rFjoqJFb2KxJ29K9ltuWRSsdA46SbN0GCxoQc36h5kg=
github.com/grafana/nanogit v0.0.0-20251106115617-c622d3e0fc4b/go.mod h1:ToqLjIdvV3AZQa3K6e5m9hy/nsGaUByc2dWQlctB9iA=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
@@ -113,8 +113,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=

View File

@@ -25,7 +25,6 @@ import (
"github.com/grafana/nanogit/options"
"github.com/grafana/nanogit/protocol"
"github.com/grafana/nanogit/protocol/hash"
"github.com/grafana/nanogit/retry"
)
type RepositoryConfig struct {
@@ -145,7 +144,7 @@ func isValidGitURL(gitURL string) bool {
// Test implements provisioning.Repository.
func (r *gitRepository) Test(ctx context.Context) (*provisioning.TestResults, error) {
ctx, _ = r.withGitContext(ctx, "")
ctx, _ = r.logger(ctx, "")
t := string(r.config.Spec.Type)
@@ -220,7 +219,7 @@ func (r *gitRepository) Test(ctx context.Context) (*provisioning.TestResults, er
// Read implements provisioning.Repository.
func (r *gitRepository) Read(ctx context.Context, filePath, ref string) (*repository.FileInfo, error) {
ctx, _ = r.withGitContext(ctx, ref)
ctx, _ = r.logger(ctx, ref)
finalPath := safepath.Join(r.gitConfig.Path, filePath)
// Resolve ref to commit hash
@@ -272,7 +271,7 @@ func (r *gitRepository) Read(ctx context.Context, filePath, ref string) (*reposi
}
func (r *gitRepository) ReadTree(ctx context.Context, ref string) ([]repository.FileTreeEntry, error) {
ctx, _ = r.withGitContext(ctx, ref)
ctx, _ = r.logger(ctx, ref)
// Resolve ref to commit hash
refHash, err := r.resolveRefToHash(ctx, ref)
@@ -320,7 +319,7 @@ func (r *gitRepository) Create(ctx context.Context, path, ref string, data []byt
if ref == "" {
ref = r.gitConfig.Branch
}
ctx, _ = r.withGitContext(ctx, ref)
ctx, _ = r.logger(ctx, ref)
branchRef, err := r.ensureBranchExists(ctx, ref)
if err != nil {
return err
@@ -365,7 +364,7 @@ func (r *gitRepository) Update(ctx context.Context, path, ref string, data []byt
if ref == "" {
ref = r.gitConfig.Branch
}
ctx, _ = r.withGitContext(ctx, ref)
ctx, _ = r.logger(ctx, ref)
// Check if trying to update a directory
if safepath.IsDir(path) {
@@ -412,7 +411,7 @@ func (r *gitRepository) Write(ctx context.Context, path string, ref string, data
ref = r.gitConfig.Branch
}
ctx, _ = r.withGitContext(ctx, ref)
ctx, _ = r.logger(ctx, ref)
info, err := r.Read(ctx, path, ref)
if err != nil && !(errors.Is(err, repository.ErrFileNotFound)) {
return fmt.Errorf("check if file exists before writing: %w", err)
@@ -432,7 +431,7 @@ func (r *gitRepository) Delete(ctx context.Context, path, ref, comment string) e
if ref == "" {
ref = r.gitConfig.Branch
}
ctx, _ = r.withGitContext(ctx, ref)
ctx, _ = r.logger(ctx, ref)
branchRef, err := r.ensureBranchExists(ctx, ref)
if err != nil {
@@ -455,7 +454,7 @@ func (r *gitRepository) Move(ctx context.Context, oldPath, newPath, ref, comment
if ref == "" {
ref = r.gitConfig.Branch
}
ctx, _ = r.withGitContext(ctx, ref)
ctx, _ = r.logger(ctx, ref)
branchRef, err := r.ensureBranchExists(ctx, ref)
if err != nil {
@@ -546,7 +545,6 @@ func (r *gitRepository) History(_ context.Context, _ string, _ string) ([]provis
}
func (r *gitRepository) ListRefs(ctx context.Context) ([]provisioning.RefItem, error) {
ctx, _ = r.withGitContext(ctx, "")
refs, err := r.client.ListRefs(ctx)
if err != nil {
return nil, fmt.Errorf("list refs: %w", err)
@@ -568,7 +566,7 @@ func (r *gitRepository) ListRefs(ctx context.Context) ([]provisioning.RefItem, e
}
func (r *gitRepository) LatestRef(ctx context.Context) (string, error) {
ctx, _ = r.withGitContext(ctx, "")
ctx, _ = r.logger(ctx, "")
branchRef, err := r.client.GetRef(ctx, fmt.Sprintf("refs/heads/%s", r.gitConfig.Branch))
if err != nil {
return "", fmt.Errorf("get branch ref: %w", err)
@@ -585,7 +583,7 @@ func (r *gitRepository) CompareFiles(ctx context.Context, base, ref string) ([]r
return nil, fmt.Errorf("ref cannot be empty")
}
ctx, logger := r.withGitContext(ctx, ref)
ctx, logger := r.logger(ctx, ref)
// Resolve base ref to hash
var baseHash hash.Hash
@@ -673,15 +671,11 @@ func (r *gitRepository) CompareFiles(ctx context.Context, base, ref string) ([]r
}
func (r *gitRepository) Stage(ctx context.Context, opts repository.StageOptions) (repository.StagedRepository, error) {
ctx = ensureRetryContext(ctx)
ctx, _ = r.withGitContext(ctx, "")
return NewStagedGitRepository(ctx, r, opts)
}
// resolveRefToHash resolves a ref (branch name or commit hash) to a commit hash
func (r *gitRepository) resolveRefToHash(ctx context.Context, ref string) (hash.Hash, error) {
ctx, _ = r.withGitContext(ctx, ref)
// Use default branch if ref is empty
if ref == "" {
ref = r.gitConfig.Branch
@@ -712,8 +706,6 @@ func (r *gitRepository) resolveRefToHash(ctx context.Context, ref string) (hash.
// ensureBranchExists checks if a branch exists and creates it if it doesn't,
// returning the branch reference to avoid duplicate GetRef calls
func (r *gitRepository) ensureBranchExists(ctx context.Context, branchName string) (nanogit.Ref, error) {
ctx, _ = r.withGitContext(ctx, branchName)
if !IsValidGitBranchName(branchName) {
return nanogit.Ref{}, &apierrors.StatusError{
ErrStatus: metav1.Status{
@@ -810,57 +802,7 @@ func (r *gitRepository) commitAndPush(ctx context.Context, writer nanogit.Staged
return nil
}
// defaultGitRetrier returns a default retrier configuration for Git operations.
//
// Retry attempts will happen when:
// - Network errors occur: connection timeouts, temporary network failures, or connection errors
// - HTTP 5xx server errors: For GET and DELETE operations (idempotent)
// - HTTP 429 Too Many Requests: For all operations (rate limiting is temporary)
//
// The retry behavior:
// - Total attempts: 8 (1 initial attempt + 7 retries)
// - Initial delay: 100ms before the first retry
// - Exponential backoff: delay doubles after each failed attempt (100ms → 200ms → 400ms → 800ms → 1.6s → 3.2s → 5s)
// - Maximum delay: capped at 5 seconds
// - Jitter: enabled to prevent thundering herd problems
// - Total retry window: approximately 10 seconds from first attempt to last retry
//
// All attempts will fail when:
// - The Git server is completely unavailable or unreachable
// - Network connectivity issues persist beyond the retry window (~10 seconds)
// - The server returns transient errors consistently for the entire retry duration
// - Context cancellation occurs before retries complete
//
// Non-transient errors (e.g., 4xx client errors except 429, authentication failures) are not retried and returned immediately.
func defaultGitRetrier() *retry.ExponentialBackoffRetrier {
return retry.NewExponentialBackoffRetrier().
WithMaxAttempts(8). // 1 initial + 7 retries = 8 total attempts (~10s total retry window)
WithInitialDelay(100 * time.Millisecond).
WithMaxDelay(5 * time.Second).
WithMultiplier(2.0).
WithJitter()
}
// ensureRetryContext ensures that retry logic is configured in the context.
// This function should be called at the beginning of all methods that make client calls
// to guarantee retry logic is always present, regardless of context state.
func ensureRetryContext(ctx context.Context) context.Context {
// Only add retrier if one doesn't already exist in the context
if retry.FromContext(ctx).MaxAttempts() <= 1 {
ctx = retry.ToContext(ctx, defaultGitRetrier())
}
return ctx
}
// withGitContext sets up the context with logging, git repository metadata, and retry logic.
// This function should be called at the beginning of all public methods to ensure:
// - Proper logging context with git repository details
// - Retry logic is configured for all Git operations
// - Context is properly prepared for nanogit client calls
func (r *gitRepository) withGitContext(ctx context.Context, ref string) (context.Context, logging.Logger) {
// Ensure retry logic is configured first, before any early returns
ctx = ensureRetryContext(ctx)
func (r *gitRepository) logger(ctx context.Context, ref string) (context.Context, logging.Logger) {
logger := logging.FromContext(ctx)
type containsGit int

View File

@@ -2163,7 +2163,7 @@ func TestGitRepository_commitAndPush(t *testing.T) {
}
}
func TestGitRepository_withGitContext(t *testing.T) {
func TestGitRepository_logger(t *testing.T) {
gitRepo := &gitRepository{
config: &provisioning.Repository{
Spec: provisioning.RepositorySpec{
@@ -2179,7 +2179,7 @@ func TestGitRepository_withGitContext(t *testing.T) {
t.Run("creates new logger context", func(t *testing.T) {
ctx := context.Background()
newCtx, logger := gitRepo.withGitContext(ctx, "feature-branch")
newCtx, logger := gitRepo.logger(ctx, "feature-branch")
require.NotNil(t, newCtx)
require.NotNil(t, logger)
@@ -2188,7 +2188,7 @@ func TestGitRepository_withGitContext(t *testing.T) {
t.Run("uses default branch when ref is empty", func(t *testing.T) {
ctx := context.Background()
newCtx, logger := gitRepo.withGitContext(ctx, "")
newCtx, logger := gitRepo.logger(ctx, "")
require.NotNil(t, newCtx)
require.NotNil(t, logger)
@@ -2198,10 +2198,10 @@ func TestGitRepository_withGitContext(t *testing.T) {
ctx := context.Background()
// First call creates the logger context
ctx1, logger1 := gitRepo.withGitContext(ctx, "branch1")
ctx1, logger1 := gitRepo.logger(ctx, "branch1")
// Second call should return the existing logger context
ctx2, logger2 := gitRepo.withGitContext(ctx1, "branch2")
ctx2, logger2 := gitRepo.logger(ctx1, "branch2")
// When logger context already exists, it should return the same context
require.Equal(t, ctx1, ctx2)

View File

@@ -6,9 +6,9 @@ require (
github.com/grafana/grafana-app-sdk v0.48.2
github.com/grafana/grafana/pkg/apimachinery v0.0.0-20250710134100-1f3dc0533caf
github.com/stretchr/testify v1.11.1
go.yaml.in/yaml/v3 v3.0.4
google.golang.org/grpc v1.76.0
google.golang.org/protobuf v1.36.10
gopkg.in/yaml.v3 v3.0.1
k8s.io/apimachinery v0.34.2
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
@@ -45,7 +45,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/woodsbury/decimal128 v1.3.0 // indirect
@@ -54,6 +54,7 @@ require (
go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect
go.yaml.in/yaml/v2 v2.4.3 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/oauth2 v0.33.0 // indirect
golang.org/x/sys v0.38.0 // indirect
@@ -62,7 +63,6 @@ require (
golang.org/x/time v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251002232023-7c0ddcbb5797 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/client-go v0.34.2 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect

View File

@@ -89,8 +89,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=

View File

@@ -29,6 +29,13 @@ SecureValueSpec: {
// +optional
ref?: string & strings.MinRunes(1) & strings.MaxRunes(1024)
// Name of the keeper, being the actual storage of the secure value.
// If not specified, the default keeper for the namespace will be used.
// +k8s:validation:minLength=1
// +k8s:validation:maxLength=253
// +optional
keeper?: string & strings.MinRunes(1) & strings.MaxRunes(253)
// The Decrypters that are allowed to decrypt this secret.
// An empty list means no service can decrypt it.
// +k8s:validation:maxItems=64
@@ -46,7 +53,4 @@ SecureValueStatus: {
// External ID where the secret is stored. Cannot be set.
// +optional
externalID: string
// The name of the keeper used to create the secure value. Cannot be set.
keeper: string
}

View File

@@ -9,7 +9,7 @@ import (
"fmt"
"strconv"
"go.yaml.in/yaml/v3"
"gopkg.in/yaml.v3"
)
const redacted = "[REDACTED]"

View File

@@ -11,7 +11,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
"go.yaml.in/yaml/v3"
"gopkg.in/yaml.v3"
)
func TestExposedSecureValue(t *testing.T) {

View File

@@ -28,7 +28,7 @@ var SecureValuesResourceInfo = utils.NewResourceInfo(
},
Reader: func(obj any) ([]any, error) {
if r, ok := obj.(*SecureValue); ok {
return []any{r.Name, r.Spec.Description, r.Status.Keeper, r.Spec.Ref}, nil
return []any{r.Name, r.Spec.Description, r.Spec.Keeper, r.Spec.Ref}, nil
}
return nil, fmt.Errorf("expected SecureValue but got %T", obj)

View File

@@ -25,6 +25,12 @@ type SecureValueSpec struct {
// +k8s:validation:maxLength=1024
// +optional
Ref *string `json:"ref,omitempty"`
// Name of the keeper, being the actual storage of the secure value.
// If not specified, the default keeper for the namespace will be used.
// +k8s:validation:minLength=1
// +k8s:validation:maxLength=253
// +optional
Keeper *string `json:"keeper,omitempty"`
// The Decrypters that are allowed to decrypt this secret.
// An empty list means no service can decrypt it.
// +k8s:validation:maxItems=64

View File

@@ -25,14 +25,12 @@ type SecureValueStatus struct {
// Version of the secure value. Cannot be set.
// +optional
Version int64 `json:"version"`
// External ID where the secret is stored. Cannot be set.
// +optional
ExternalID string `json:"externalID"`
// operatorStates is a map of operator ID to operator state evaluations.
// Any operator which consumes this kind SHOULD add its state evaluation information to this field.
OperatorStates map[string]SecureValuestatusOperatorState `json:"operatorStates,omitempty"`
// The name of the keeper used to create the secure value. Cannot be set.
Keeper string `json:"keeper"`
// External ID where the secret is stored. Cannot be set.
// +optional
ExternalID string `json:"externalID"`
// additionalFields is reserved for future use
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"`
}

View File

@@ -587,6 +587,15 @@ func schema_pkg_apis_secret_v1beta1_SecureValueSpec(ref common.ReferenceCallback
Format: "",
},
},
"keeper": {
SchemaProps: spec.SchemaProps{
Description: "Name of the keeper, being the actual storage of the secure value. If not specified, the default keeper for the namespace will be used.",
MinLength: ptr.To[int64](1),
MaxLength: ptr.To[int64](253),
Type: []string{"string"},
Format: "",
},
},
"decrypters": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
@@ -630,14 +639,6 @@ func schema_pkg_apis_secret_v1beta1_SecureValueStatus(ref common.ReferenceCallba
Format: "int64",
},
},
"externalID": {
SchemaProps: spec.SchemaProps{
Description: "External ID where the secret is stored. Cannot be set.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"operatorStates": {
SchemaProps: spec.SchemaProps{
Description: "operatorStates is a map of operator ID to operator state evaluations. Any operator which consumes this kind SHOULD add its state evaluation information to this field.",
@@ -653,9 +654,9 @@ func schema_pkg_apis_secret_v1beta1_SecureValueStatus(ref common.ReferenceCallba
},
},
},
"keeper": {
"externalID": {
SchemaProps: spec.SchemaProps{
Description: "The name of the keeper used to create the secure value. Cannot be set.",
Description: "External ID where the secret is stored. Cannot be set.",
Default: "",
Type: []string{"string"},
Format: "",
@@ -677,7 +678,6 @@ func schema_pkg_apis_secret_v1beta1_SecureValueStatus(ref common.ReferenceCallba
},
},
},
Required: []string{"keeper"},
},
},
Dependencies: []string{

View File

@@ -35,7 +35,7 @@ require (
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f // indirect
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4 // indirect
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37 // indirect
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
@@ -56,7 +56,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.3 // indirect
github.com/prometheus/common v0.67.2 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/puzpuzpuz/xsync/v2 v2.5.1 // indirect
github.com/spf13/pflag v1.0.10 // indirect

View File

@@ -52,8 +52,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f h1:Cbm6OKkOcJ+7CSZsGsEJzktC/SIa5bxVeYKQLuYK86o=
github.com/grafana/authlib v0.0.0-20250930082137-a40e2c2b094f/go.mod h1:axY0cdOg3q0TZHwpHnIz5x16xZ8ZBxJHShsSHHXcHQg=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4 h1:Muoy+FMGrHj3GdFbvsMzUT7eusgii9PKf9L1ZaXDDbY=
github.com/grafana/authlib/types v0.0.0-20251119142549-be091cf2f4d4/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37 h1:qEwZ+7MbPjzRvTi31iT9w7NBhKIpKwZrFbYmOZLqkwA=
github.com/grafana/authlib/types v0.0.0-20250926065801-df98203cff37/go.mod h1:qeWYbnWzaYGl88JlL9+DsP1GT2Cudm58rLtx13fKZdw=
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4 h1:jSojuc7njleS3UOz223WDlXOinmuLAIPI0z2vtq8EgI=
github.com/grafana/dskit v0.0.0-20250908063411-6b6da59b5cc4/go.mod h1:VahT+GtfQIM+o8ht2StR6J9g+Ef+C2Vokh5uuSmOD/4=
github.com/grafana/grafana-app-sdk v0.48.2 h1:CQQDhwo1fWaXQVKvxxOcK6azbuY3E2TgJHNAZlYYn7U=
@@ -116,8 +116,8 @@ github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h
github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
github.com/prometheus/common v0.67.3 h1:shd26MlnwTw5jksTDhC7rTQIteBxy+ZZDr3t7F2xN2Q=
github.com/prometheus/common v0.67.3/go.mod h1:gP0fq6YjjNCLssJCQp0yk4M8W6ikLURwkdd/YKtTbyI=
github.com/prometheus/common v0.67.2 h1:PcBAckGFTIHt2+L3I33uNRTlKTplNzFctXcWhPyAEN8=
github.com/prometheus/common v0.67.2/go.mod h1:63W3KZb1JOKgcjlIr64WW/LvFGAqKPj0atm+knVGEko=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU=

View File

@@ -1959,10 +1959,6 @@ max_connections = 100
# The limit can be disabled by setting it to -1.
message_size_limit = 8388608
# client_queue_max_size is the maximum size in bytes of the client queue
# for Live connections. Defaults to 4MB.
client_queue_max_size = 4194304
# allowed_origins is a comma-separated list of origins that can establish connection with Grafana Live.
# If not set then origin will be matched over root_url. Supports wildcard symbol "*".
allowed_origins =

View File

@@ -1903,10 +1903,6 @@ default_datasource_uid =
# ha_prefix is a prefix for keys in the HA engine. It's used to separate keys for different Grafana instances.
;ha_prefix =
# client_queue_max_size is the maximum size in bytes of the client queue
# for Live connections. Defaults to 4MB.
;client_queue_max_size =
#################################### Grafana Image Renderer Plugin ##########################
[plugin.grafana-image-renderer]
# Instruct headless browser instance to use a default timezone when not provided by Grafana, e.g. when rendering panel image of alert.

View File

@@ -13,7 +13,7 @@ import (
"os"
"strings"
"go.yaml.in/yaml/v3"
"gopkg.in/yaml.v3"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/grafana/grafana/apps/scope/pkg/apis/scope/v0alpha1"

View File

@@ -73,37 +73,6 @@ To access the History page, complete the following steps.
{{< figure src="/media/docs/alerting/alerting-alert-history-tab.png" max-width="750px" alt="Alert History tab in Grafana Alerting" >}}
## Use Grafana Assistant to analyze alert state history
{{< admonition type="note" >}}
This feature is available in Grafana Cloud when Grafana Assistant is enabled.
{{< /admonition >}}
The **Analyze with Assistant** button provides AI-powered analysis of your alert history to help you understand and troubleshoot alert patterns. Located in the top-right corner of the History page event list, this button uses Grafana Assistant to analyze the events displayed in your current view.
When you click the AI Triage button, the Grafana Assistant analyzes:
- Alert state transitions over the selected time range
- Alert instance patterns and frequency
- Common labels and characteristics of firing alerts
- Temporal patterns in alert behavior
The AI assistant can help you:
- Identify root causes of alert storms
- Detect patterns in alert firing behavior
- Understand correlations between different alert instances
- Get suggestions for improving alert configurations
To use the Analyze with Assistant feature:
1. Navigate to the History page as described above.
2. Filter the events to focus on the alerts you want to analyze using labels, states, or time range.
3. Click the **Analyze with Assistant** button in the top-right corner of the event list.
4. Review the AI-generated analysis and recommendations.
The AI analysis is based on the currently displayed events, so filtering your view to specific alerts or time periods will result in more focused insights.
## View from the State history view
Use the State history view to get insight into how your individual alert instances behave over time.

View File

@@ -4,23 +4,17 @@ keywords:
- Quickstart
- Grafana Cloud
menuTitle: Infrastructure as code
title: Provision Grafana Cloud with Infrastructure as code
title: Provision Grafana Cloud with infrastructure as code
weight: 800
labels:
products:
- cloud
canonical: https://grafana.com/docs/grafana/latest/as-code/infrastructure-as-code/
---
# Provision Grafana Cloud with Infrastructure as code
# Provision Grafana Cloud with infrastructure as code
With Grafana Cloud, you can use as-code tools to create and manage resources via code, and incorporate them efficiently into your own use cases. This enables you to review code, reuse it, and create better workflows.
With Grafana Cloud, you can create dashboards via configuration files in source code. This enables you to review code, reuse it, and create better workflows.
{{< admonition type="note" >}}
Most of the tools defined here can be used with one another.
{{< /admonition >}}
Via code, you can _declaratively_ manage _what_ Grafana resources to use.
The as-code tools and tutorials that follow show you what do to, to declaratively manage Grafana resources, and incorporate them efficiently into your own use cases.
## Grafana Terraform provider
@@ -73,7 +67,7 @@ To get started, see the [quickstart guides for the Grafana Ansible Collection](/
### Who is this recommended for?
Like Terraform, the Grafana Ansible collection is best suited for people already using Ansible for non-Grafana use cases. The collection only works for Grafana Cloud right now, so it makes the most sense for Grafana Cloud customers who want to manage resources using Ansible.
Like Terraform, the Grafana Ansible collection is best suited for people already using Ansible for non-Grafana use cases. The collection only works for Grafana Cloud right now, so it makes the most sense for Grafana Cloud customers who want to manage resources declaratively using Ansible.
### Known limitations
@@ -81,7 +75,7 @@ The Grafana Ansible collection only works for Grafana Cloud and only supports ei
## Grafana Operator
The Grafana Operator is a Kubernetes operator that can provision, manage, and operate Grafana instances and their associated resources within Kubernetes through Custom Resources. This Kubernetes-native tool eases the administration of Grafana, including managing dashboards, data sources, and folders. It also automatically syncs the Kubernetes Custom resources and the actual resources in the Grafana Instance. It supports leveraging Grafonnet for generating Grafana dashboard definitions for seamless dashboard configuration as code.
The Grafana Operator is a Kubernetes operator that can provision, manage, and operate Grafana instances and their associated resources within Kubernetes through Custom Resources. This Kubernetes-native tool eases the administration of Grafana, offering a declarative approach to managing dashboards, data sources, and folders. It also automatically syncs the Kubernetes Custom resources and the actual resources in the Grafana Instance. It supports leveraging Grafonnet for generating Grafana dashboard definitions for seamless dashboard configuration as code.
To get started, see the [quickstart guides for the Grafana Operator](/docs/grafana-cloud/as-code/infrastructure-as-code/grafana-operator/) or check out the [Grafana Operator's documentation](https://grafana.github.io/grafana-operator/).
@@ -126,7 +120,7 @@ To get started with the Grafana Crossplane provider, install Crossplane in the K
kubectl crossplane install provider grafana/crossplane-provider-grafana:v0.1.0
```
During installation of the provider, CRDs for all the resources supported by the Terraform provider are added to the cluster so users can begin defining their Grafana resources as Kubernetes custom resources. The Crossplane provider ensures that whatever is defined in the custom resource definitions is what is visible in Grafana UI. If any changes are made directly in the UI, the changes will be discarded when the provider resyncs. This helps ensure that whatever is defined via code in the cluster will be the source of truth for Grafana resources.
During installation of the provider, CRDs for all the resources supported by the Terraform provider are added to the cluster so users can begin defining their Grafana resources as Kubernetes custom resources. The Crossplane provider ensures that whatever is defined in the custom resource definitions is what is visible in Grafana UI. If any changes are made directly in the UI, the changes will be discarded when the provider resyncs. This helps ensure that whatever is defined declaratively in the cluster will be the source of truth for Grafana resources.
To get started, refer to the examples folder in the Grafana Crossplane repository.
@@ -158,15 +152,16 @@ To use the Crossplane provider, you must have the Crossplane CLI and Crossplane
## Grafana as code comparison
Most of the tools defined here can be used with one another.
The following chart compares the properties and tools mentioned above.
| Property/Tool | Grafana Terraform Provider | Grafana Ansible Collection | Grafana Operator | Grafana Crossplane Provider |
| -------------------------------------- | --------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- |
| Grafana resources supported | All major Grafana resources | Grafana Cloud stack, plugins, API keys, dashboards, data sources, and folders | Dashboards, data sources, Folders | All major Grafana resources |
| Tool format | HCL/JSON | YAML | YAML | YAML/JSON |
| Follows Kubernetes-style manifests | | | ✓ | ✓ |
| Easy dashboard building process | | | ✓ | |
| Manage resources using Kubernetes | | | ✓ | ✓ |
| Retrieves Grafana resource information | ✓ | | | |
| Built-in resource sync process | | | ✓ | ✓ |
| Recommended for | Existing Terraform users | Existing Ansible users | Users looking to manage Grafana resources from within Kubernetes | Users looking to manage Grafana resources from within Kubernetes |
| Property/Tool | Grafana Terraform Provider | Grafana Ansible Collection | Grafana Operator | Grizzly | Grafana Crossplane Provider |
| -------------------------------------- | --------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| Grafana resources supported | All major Grafana resources | Grafana Cloud stack, plugins, API keys, dashboards, data sources, and folders | Dashboards, Datasources, Folders | Synthetic Monitoring checks, dashboards, data sources, folders, and Prometheus rules | All major Grafana resources |
| Tool format | HCL/JSON | YAML | YAML | Jsonnet/YAML/JSON | YAML/JSON |
| Follows Kubernetes-style manifests | | | ✓ | ✓ | ✓ |
| Easy dashboard building process | | | ✓ | ✓ | |
| Manage resources using Kubernetes | | | ✓ | | ✓ |
| Retrieves Grafana resource information | ✓ | | | | |
| Built-in resource sync process | | | ✓ | ✓ | ✓ |
| Recommended for | Existing Terraform users | Existing Ansible users | Users looking to manage Grafana resources from within Kubernetes | Users looking to define Grafana resources in a Kubernetes-style YAML and users looking to get built-in workflow support and sync process | Users looking to manage Grafana resources from within Kubernetes |

View File

@@ -8,42 +8,22 @@ menuTitle: Ansible
title: Grafana Ansible collection
weight: 110
canonical: https://grafana.com/docs/grafana/latest/as-code/infrastructure-as-code/ansible/
aliases:
- ../../infrastructure-as-code/ansible/ansible-grafana-agent-linux
- ../../infrastructure-as-code/ansible/ansible-multiple-agents
labels:
products:
- cloud
---
# Grafana Ansible collection
The [Grafana Ansible collection](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/) provides configuration management resources for Grafana. You can use it to manage:
The [Grafana Ansible collection](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/) provides configuration management resources for Grafana. You can use it to manage resources such as dashboards, Cloud stacks, folders, and more.
- Grafana Cloud stacks
- Dashboards
- Data sources
- Folders
- Alerting contact points
- Notification policies
- API keys
If your resources aren't currently available in the Grafana Ansible collection, you can manage them on Grafana Cloud programmatically by writing Ansible playbooks that use the [Ansible's built-in URI module](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/uri_module.html) to call the [HTTP APIs](/docs/grafana/latest/developers/http_api/) to manage resources for the Grafana Cloud portal, as well as those within a stack.
## Learn more
Refer to [Create and manage a Grafana Cloud stack using Ansible](ansible-cloud-stack/) to learn how to create a Grafana Cloud stack and add a data source and dashboard using [Ansible](https://www.ansible.com/).
To learn more about managing Grafana with Infrastructure as code:
- [Grafana Ansible collection documentation](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/)
- [Ansible playbook best practices](https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html)
- [Grafana API documentation](/docs/grafana/latest/developers/http_api/)
- [Grafana Cloud API documentation](https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/)
- [Infrastructure as Code with Terraform](/docs/grafana/latest/as-code/infrastructure-as-code/terraform/)
## Grafana Agent (deprecated)
The collection also houses the [Grafana Agent role](https://github.com/grafana/grafana-ansible-collection/tree/main/roles/grafana_agent) which can be used to deploy and manage Grafana Agent across various Linux machines.
{{< docs/shared lookup="agent-deprecation.md" source="alloy" version="next" >}}
The Ansible collection also houses [Grafana Agent role](https://github.com/grafana/grafana-ansible-collection/tree/main/roles/grafana_agent), which is now deprecated.
For resources currently not available in the Grafana Ansible collection, you can manage those resources on Grafana Cloud programmatically by writing Ansible playbooks that use the [Ansible's builtin uri module](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/uri_module.html) to call the [HTTP APIs](/docs/grafana/latest/developers/http_api/) to manage resources for the Grafana Cloud portal, as well as those within a stack.
Use the following guides to get started using Ansible to manage your Grafana Cloud stack:
| Topic | Description |
| ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| [Create and manage a Grafana Cloud stack using Ansible](ansible-cloud-stack/) | Describes how to create a Grafana Cloud stack and add a data source and dashboard using [Ansible](https://www.ansible.com/). |
| [Install Grafana Agent on a Linux host using Ansible](ansible-grafana-agent-linux/) | Describes how to install the Grafana Agent on a Linux node using Ansible and use it to push logs to Grafana Cloud. |
| [Monitor multiple Linux hosts with Grafana Agent Role](ansible-multiple-agents/) | Describes how to use the Grafana Ansible collection to manage agents across multiple Linux hosts. |

View File

@@ -4,78 +4,64 @@ keywords:
- Quickstart
- Grafana Cloud
- Ansible
title: Create and manage your Grafana Cloud stack using Ansible
menuTitle: Manage stack using Ansible
title: Create and manage a Grafana Cloud stack using Ansible
weight: 100
canonical: https://grafana.com/docs/grafana/latest/as-code/infrastructure-as-code/ansible/ansible-cloud-stack/
---
# Create and manage your Grafana Cloud stack using Ansible
# Create and manage a Grafana Cloud stack using Ansible
This guide shows you how to create a Grafana Cloud stack and add a data source, dashboard, and folder using the Ansible Collection for Grafana. You'll manage your Grafana infrastructure through Ansible playbooks.
Learn how to add a data source, a dashboard, and a folder to a Grafana Cloud stack using Ansible collection for Grafana.
## Before you begin
Before you begin, make sure you have the following available:
Before you begin, you should have the following available:
- A Grafana Cloud account
- A Grafana Cloud account.
- [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/index.html) installed on your machine
## Install the Grafana Ansible collection
Install the Grafana Ansible collection:
```sh
ansible-galaxy collection install grafana.grafana
```
This collection provides all the modules needed to manage Grafana Cloud stacks and resources.
## Create a Cloud stack
First, create a Grafana Cloud Access Policy and get a token. You'll need this for the Ansible playbook to be able to create a Grafana Cloud stack. Refer to [Create a Grafana Cloud Access Policy](/docs/grafana-cloud/security-and-account-management/authentication-and-permissions/access-policies/create-access-policies/).
1. Create a Grafana Cloud Access Policy and get a token.
You'll need this for the Ansible playbook to be able to create a Grafana Cloud stack.
Refer to [Create a Grafana Cloud Access Policy](/docs/grafana-cloud/security-and-account-management/authentication-and-permissions/access-policies/create-access-policies/).
Next, create an Ansible playbook file. This Ansible playbook creates a Grafana Cloud stack using the [Cloud stack module](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/cloud_stack_module.html#ansible-collections-grafana-grafana-cloud-stack-module).
1. Create an Ansible playbook file.
To do so, create a file named `cloud-stack.yml` and add the following:
This Ansible playbook will create a Grafana Cloud stack by using the [Cloud stack module](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/cloud_stack_module.html#ansible-collections-grafana-grafana-cloud-stack-module).
```yaml
- name: Create Grafana Cloud stack
connection: local
hosts: localhost
Create a file named `cloud-stack.yml` and add the following:
vars:
grafana_cloud_api_key: '<CLOUD_ACCESS_POLICY_TOKEN>'
stack_name: '<STACK_NAME>'
org_name: '<ORG_NAME>'
```yaml
- name: Create Grafana Cloud stack
connection: local
hosts: localhost
tasks:
- name: Create a Grafana Cloud stack
grafana.grafana.cloud_stack:
name: '{{ stack_name }}'
stack_slug: '{{ stack_name }}'
cloud_api_key: '{{ grafana_cloud_api_key }}'
org_slug: '{{ org_name }}'
delete_protection: true
state: present
register: stack_result
vars:
grafana_cloud_api_key: '<Your Cloud Access Policy token>'
stack_name: '<stack-name>'
org_name: '<org-name>'
- name: Display stack URL
debug:
msg: 'Stack created at: {{ stack_result.url }}'
```
tasks:
- name: Create a Grafana Cloud stack
grafana.grafana.cloud_stack:
name: '{{ stack_name }}'
stack_slug: '{{ stack_name }}'
cloud_api_key: '{{ grafana_cloud_api_key }}'
org_slug: '{{ org_name }}'
delete_protection: true
state: present
```
Replace the placeholders with your values:
1. Replace the following field values:
- `<token>` with a token from the Cloud Access Policy you created in the Grafana Cloud portal.
- `<stack-name>` with the name of your stack.
- `<org-name>` with the name of the organization in Grafana Cloud.
- _`<CLOUD_ACCESS_POLICY_TOKEN>`_: Token from the Cloud Access Policy you created in the Grafana Cloud portal
- _`<STACK_NAME>`_: Name of your stack
- _`<ORG_NAME>`_: Name of the organization in Grafana Cloud
## Create an API key in the Grafana stack
The playbook registers the stack creation result and displays the stack URL, which you'll need for subsequent resource management.
## Create an API key in your Grafana stack
Create an API key in the Grafana stack. You'll need this key to configure Ansible to create data sources, folders, and dashboards.
Create an API key in the Grafana stack.
You'll need this key to configure Ansible to be able to create data source, folders, and dashboards.
1. Log into your Grafana Cloud instance.
2. Click **Administration** and select **API keys**.
@@ -84,169 +70,171 @@ Create an API key in the Grafana stack. You'll need this key to configure Ansibl
5. In **Role**, select **Admin** or **Editor** to associate the role with this API key.
6. Click **Copy** to save it for later use.
## Add resources using playbooks
## Add a data source
### Add a data source
This guide uses the InfluxDB data source.
The required arguments vary depending on the type of data source you select.
The following steps use the InfluxDB data source. The required arguments vary depending on the type of data source you select.
1. Create a file named `data-source.yml` and add the following:
Create a file named `data-source.yml`:
```yaml
- name: Add/Update data source
connection: local
hosts: localhost
```yaml
- name: Add/Update data source
connection: local
hosts: localhost
vars:
data_sources:
[
{
name: '<data-source-name>',
type: 'influxdb',
url: '<data-source-url>',
user: '<username>',
secureJsonData: { password: '<password>' },
database: '<db-name>',
id: <id>,
uid: '<uid>',
access: 'proxy',
},
]
vars:
grafana_url: 'https://<STACK_NAME>.grafana.net'
grafana_api_key: '<GRAFANA_API_KEY>'
data_source_config:
name: '<DATA_SOURCE_NAME>'
type: 'influxdb'
url: '<DATA_SOURCE_URL>'
user: '<USERNAME>'
secureJsonData:
password: '<PASSWORD>'
database: '<DATABASE_NAME>'
uid: '<UID>'
access: 'proxy'
grafana_api_key: '<API-Key>'
stack_name: '<stack-name>'
tasks:
- name: Create/Update Data source
grafana.grafana.datasource:
dataSource: '{{ data_source_config }}'
grafana_url: '{{ grafana_url }}'
grafana_api_key: '{{ grafana_api_key }}'
state: present
```
tasks:
- name: Create/Update Data sources
grafana.grafana.datasource:
datasource: '{{ item }}'
stack_slug: '{{ stack_name }}'
grafana_api_key: '{{ grafana_api_key }}'
state: present
loop: '{{ data_sources }}'
```
Replace the placeholders with your values:
1. Replace the following field values:
- `<data-source-name>` with the name of the data source to be added in Grafana.
- `<data-source-url>` with URL of your data source.
- `<username>` with the username for authenticating with your data source.
- `<password>` with the password for authenticating with your data source.
- `<db-name>` with name of your database.
- `<id>` with the ID for your data source in Grafana.
- `<uid>` wth the UID for your data source in Grafana.
- `<stack-name>` with the name of your stack.
- `<API-key>` with the [API key created in the Grafana instance](#create-an-api-key-in-the-grafana-stack).
- _`<DATA_SOURCE_NAME>`_: Name of the data source to be added in Grafana
- _`<DATA_SOURCE_URL>`_: URL of your data source
- _`<USERNAME>`_: Username for authenticating with your data source
- _`<PASSWORD>`_: Password for authenticating with your data source
- _`<DATABASE_NAME>`_: Name of your database
- _`<UID>`_: UID for your data source in Grafana
- _`<STACK_NAME>`_: Name of your stack
- _`<GRAFANA_API_KEY>`_: API key created in the Grafana instance
## Add a folder
### Add a folder
This Ansible playbook creates a folder in your Grafana instance by using the [Folder module](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/folder_module.html#ansible-collections-grafana-grafana-folder-module).
This playbook creates a folder in your Grafana instance using the [Folder module](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/folder_module.html#ansible-collections-grafana-grafana-folder-module).
1. Create a file named `folder.yml` and add the following:
Create a file named `folder.yml`:
```yaml
- name: Add/Update Folders
connection: local
hosts: localhost
```yaml
- name: Add/Update Folders
connection: local
hosts: localhost
vars:
folders: [{ title: '<folder-name>', uid: '<uid>' }]
vars:
grafana_url: 'https://<STACK_NAME>.grafana.net'
grafana_api_key: '<GRAFANA_API_KEY>'
folders:
- title: '<FOLDER_NAME>'
uid: '<UID>'
stack_name: '<stack-name>'
grafana_api_key: <API-key>
tasks:
- name: Create/Update a Folder in Grafana
grafana.grafana.folder:
title: '{{ item.title }}'
uid: '{{ item.uid }}'
grafana_url: '{{ grafana_url }}'
grafana_api_key: '{{ grafana_api_key }}'
state: present
loop: '{{ folders }}'
```
tasks:
- name: Create/Update a Folder in Grafana
grafana.grafana.folder:
title: '{{ item.title }}'
uid: '{{ item.uid }}'
stack_slug: '{{ stack_name }}'
grafana_api_key: '{{ grafana_api_key }}'
state: present
loop: '{{ folders }}'
```
Replace the placeholders with your values:
1. Replace the following field values:
- `<folder-name>` with the name of the folder to be added in Grafana.
- `<uid>` with the UID for your folder in Grafana.
- `<stack-name>` with the name of your stack.
- `<API-key>` with the [API key created in the Grafana instance](#create-an-api-key-in-the-grafana-stack).
- _`<FOLDER_NAME>`_: Name of the folder to be added in Grafana
- _`<UID>`_: UID for your folder in Grafana
- _`<STACK_NAME>`_: Name of your stack
- _`<GRAFANA_API_KEY>`_: API key created in the Grafana instance
## Add a dashboard to the folder
### Add a dashboard to the folder
This Ansible playbook iterates through the dashboard JSON source code files in the folder referenced in `dashboards_path` and adds them in the Grafana instance by using the [Dashboard module](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/dashboard_module.html#ansible-collections-grafana-grafana-dashboard-module).
This playbook iterates through the dashboard JSON source code files in the folder referenced in `dashboards_path` and adds them to the Grafana instance using the [Dashboard module](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/dashboard_module.html#ansible-collections-grafana-grafana-dashboard-module).
1. Create a file named `dashboard.yml` and add the following:
Create a file named `dashboard.yml`:
```yaml
- name: Add/Update Dashboards
connection: local
hosts: localhost
```yaml
- name: Add/Update Dashboards
connection: local
hosts: localhost
vars:
dashboards_path: <path-to-dashboard-files> # Example "./dashboards"
stack_name: "<stack-name>"
grafana_api_key: <API-key>
vars:
grafana_url: 'https://<STACK_NAME>.grafana.net'
grafana_api_key: '<GRAFANA_API_KEY>'
dashboards_path: '<PATH_TO_DASHBOARD_FILES>' # Example "./dashboards"
tasks:
- name: Find dashboard files
find:
paths: "{{ dashboards_path }}"
file_type: file
recurse: Yes
patterns: "*.json"
register: files_matched
no_log: True
tasks:
- name: Find dashboard files
find:
paths: '{{ dashboards_path }}'
file_type: file
recurse: true
patterns: '*.json'
register: files_matched
no_log: true
- name: Create list of dashboard file names
set_fact:
dashboard_file_names: "{{ dashboard_file_names | default ([]) + [item.path] }}"
loop: "{{ files_matched.files }}"
no_log: True
- name: Create list of dashboard file names
set_fact:
dashboard_file_names: '{{ dashboard_file_names | default([]) + [item.path] }}'
loop: '{{ files_matched.files }}'
no_log: true
- name: Create/Update a dashboard
grafana.grafana.dashboard:
dashboard: "{{ lookup('ansible.builtin.file','{{ item }}' ) }}"
stack_slug: "{{ stack_name }}"
grafana_api_key: "{{ grafana_api_key }}"
state: present
loop: "{{ dashboard_file_names }}"
```
- name: Create/Update a dashboard
grafana.grafana.dashboard:
dashboard: "{{ lookup('ansible.builtin.file', item) }}"
grafana_url: '{{ grafana_url }}'
grafana_api_key: '{{ grafana_api_key }}'
state: present
loop: '{{ dashboard_file_names }}'
```
Replace the placeholders with your values:
- _`<PATH_TO_DASHBOARD_FILES>`_: Path to the folder containing dashboard JSON source code files
- _`<STACK_NAME>`_: Name of your stack
- _`<GRAFANA_API_KEY>`_: API key created in the Grafana instance
1. Replace the following field values:
- `<path-to-dashboard-files>` with the path to the folder containing dashboard JSON source code files.
- `<stack-name>` with the name of your stack.
- `<API-key>` with the [API key created in the Grafana instance](#create-an-api-key-in-the-grafana-stack).
## Run the Ansible playbooks
In a terminal, run the following commands from the directory where all of the Ansible playbooks are located.
Create the Grafana Cloud stack:
1. To create the Grafana Cloud stack.
```sh
ansible-playbook cloud-stack.yml
```
```shell
ansible-playbook cloud-stack.yml
```
Add a data source to the Grafana stack:
1. To add a data source to the Grafana stack.
```sh
ansible-playbook data-source.yml
```
```shell
ansible-playbook data-source.yml
```
Add a folder to the Grafana stack:
1. To add a folder to the Grafana stack
```sh
ansible-playbook folder.yml
```
```shell
ansible-playbook folder.yml
```
Add a dashboard to the folder in your Grafana stack:
1. To add a dashboard to the folder in your Grafana stack.
```sh
ansible-playbook dashboard.yml
```
```shell
ansible-playbook dashboard.yml
```
## Validate your configuration
## Validation
After you've run the Ansible playbooks, you can verify the following:
Once you run the Ansible playbooks, you should be able to verify the following:
- The new Grafana Cloud stack is created and visible in the Cloud Portal.
- The new Grafana stack is created and visible in the Cloud Portal.
![Cloud Portal](/static/img/docs/grafana-cloud/terraform/cloud_portal_tf.png)
@@ -254,22 +242,18 @@ After you've run the Ansible playbooks, you can verify the following:
![InfluxDB datasource](/media/docs/grafana-cloud/screenshot-influxdb_datasource_tf.png)
- A new folder is available in your Grafana stack. In the following image, a folder named `Demos` was added.
- A new folder in Grafana.
In the following image, a folder named `Demos` was added.
![Folder](/media/docs/grafana-cloud/screenshot-folder_tf.png)
- A new dashboard is visible in the Grafana stack. In the following image, a dashboard named `InfluxDB Cloud Demos` was created inside the "Demos" folder.
- A new dashboard in the Grafana stack.
In the following image a dashboard named `InfluxDB Cloud Demos` was created inside the "Demos" folder.
![InfluxDB dashboard](/static/img/docs/grafana-cloud/terraform/influxdb_dashboard_tf.png)
## Next steps
## Summary
You've successfully created a Grafana Cloud stack along with a data source, a folder, and a dashboard using Ansible. Your Grafana infrastructure is now managed through code.
In this guide, you created a Grafana Cloud stack along with a data source, folder, and dashboard imported from a JSON file using Ansible.
To learn more about managing Grafana with Infrastructure as code:
- [Grafana Ansible collection documentation](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/)
- [Ansible playbook best practices](https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html)
- [Grafana API documentation](/docs/grafana/latest/developers/http_api/)
- [Grafana Cloud API documentation](https://grafana.com/docs/grafana-cloud/developer-resources/api-reference/)
- [Infrastructure as Code with Terraform](/docs/grafana/latest/as-code/infrastructure-as-code/terraform/)
To learn more about managing Grafana using Ansible, refer to the [Grafana Ansible collection](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/).

View File

@@ -0,0 +1,156 @@
---
keywords:
- Infrastructure as Code
- Quickstart
- Grafana Cloud
- Ansible
title: Install Grafana Agent on a Linux host using Ansible
weight: 200
canonical: https://grafana.com/docs/grafana/latest/as-code/infrastructure-as-code/ansible/ansible-grafana-agent-linux/
---
# Install Grafana Agent on a Linux host using Ansible
{{< docs/shared lookup="agent-deprecation.md" source="alloy" version="next" >}}
This guide shows how to install Grafana Agent on a Linux host using [Ansible](https://www.ansible.com/) and to use it to push logs to Grafana Cloud.
## Before you begin
Before you begin, you should have the following available:
- A Grafana Cloud account.
- A Linux machine
- Command line (terminal) access to that Linux machine with `unzip` binary installed
- Account permissions sufficient to install and use Grafana Agent on the Linux machine
- [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/index.html) installed on the Linux machine
## Choose your Grafana Agent installation method
This guide covers two methods for installing and configuring Grafana Agent using Ansible:
- Installing Grafana Agent in Flow mode
- Installing Grafana Agent in static mode
Depending on your specific needs and the configuration of your environment, you may choose one method over the other for better compatibility or ease of setup.
<!-- vale Grafana.Spelling = NO -->
### Install Grafana Agent in flow mode using Ansible
This Ansible playbook installs Grafana Agent in Flow mode and also creates a systemd service to manage it.
It creates a user named `grafana-agent` on the Linux machine for running Grafana Agent.
1. Create a file named `grafana-agent.yml` and add the following:
```yaml
- name: Install Grafana Agent Flow
hosts: all
become: true
tasks:
- name: Install Grafana Agent Flow
ansible.builtin.include_role:
name: grafana.grafana.grafana_agent
vars:
grafana_agent_mode: flow
# Change config file on the host to .river
grafana_agent_config_filename: config.river
# Change config file to be copied
grafana_agent_provisioned_config_file: '<path-to-config-file>'
# Remove default flags
grafana_agent_flags_extra:
server.http.listen-addr: '0.0.0.0:12345'
```
1. Replace the following field values:
- `<path-to-config-file-on-localhost>` with the path to river configuration file on the Ansible Controller (Localhost).
### Install Grafana Agent in static mode using Ansible
This Ansible playbook installs Grafana Agent in static mode and also creates a systemd service to manage it.
It creates a user named `grafana-agent` on the Linux machine for running Grafana Agent.
1. Create a file named `grafana-agent.yml` and add the following:
```yaml
- name: Install Grafana Agent in static mode
hosts: all
become: true
vars:
grafana_cloud_api_key: <Your Cloud Access Policy token>
logs_username: <loki-username> # Example - 411478
loki_url: <loki-push-url> # Example - https://logs-prod-017.grafana.net/loki/api/v1/push
tasks:
- name: Install Grafana Agent in static mode
ansible.builtin.include_role:
name: grafana_agent
vars:
grafana_agent_logs_config:
configs:
- clients:
- basic_auth:
password: '{{ grafana_cloud_api_key }}'
username: '{{ logs_username }}'
url: '{{ loki_url }}'
name: default
positions:
filename: /tmp/positions.yaml
scrape_configs:
- job_name: integrations/node_exporter_direct_scrape
static_configs:
- targets:
- localhost
labels:
instance: hostname
__path__: /var/log/*.log
job: integrations/node_exporter
target_config:
sync_period: 10s
```
1. Replace the following field values:
- `<Your Cloud Access Policy token>` with a token from the Cloud Access Policy you created in the Grafana Cloud portal.
- `<loki-username>` with the Loki Username
- `<loki-push-url>` with the push endpoint URL of Loki Instance
## Run the Ansible playbook on the Linux machine
In the Linux machine's terminal, run the following command from the directory where the Ansible playbook is located.
```shell
ansible-playbook grafana-agent.yml
```
## Validate
<!-- vale Grafana.ReferTo = NO -->
1. Grafana Agent service on the Linux machine should be `active` and `running`. You should see a similar output:
<!-- vale Grafana.ReferTo = NO -->
```shell
$ sudo systemctl status grafana-agent.service
grafana-agent.service - Grafana Agent
Loaded: loaded (/etc/systemd/system/grafana-agent.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-07-20 09:56:15 UTC; 36s ago
Main PID: 3176 (agent-linux-amd)
Tasks: 8 (limit: 515)
Memory: 92.5M
CPU: 380ms
CGroup: /system.slice/grafana-agent.service
└─3176 /usr/local/bin/agent-linux-amd64 --config.file=/etc/grafana-cloud/agent-config.yaml
```
1. In a Grafana Cloud stack, click **Explore** in the left-side menu.
1. At the top of the page, use the dropdown menu to select your Loki logs data source. In the Log Browser, run the query `{job="integrations/node_exporter"}`
![Loki Logs](/static/img/docs/grafana-cloud/ansible/ansible-agent-logs.png)
## Summary
In this guide, you installed Grafana Agent on a Linux node using Ansible and used it to pushed logs to Grafana Cloud.
To learn more about the Grafana Ansible collection, refer to the [GitHub repository](https://github.com/grafana/grafana-ansible-collection) or its [documentation](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/index.html).

View File

@@ -0,0 +1,207 @@
---
menuTitle: Monitor multiple Linux hosts with the grafana_agent role
title: Monitor multiple Linux hosts with grafana_agent role
weight: 300
canonical: https://grafana.com/docs/grafana/latest/as-code/infrastructure-as-code/ansible/ansible-multiple-agents/
---
# Monitor multiple Linux hosts with the `grafana_agent` role
{{< docs/shared lookup="agent-deprecation.md" source="alloy" version="next" >}}
Monitoring multiple Linux hosts can be difficult.
To make it easier, you can use the `grafana_agent` role with the [Grafana Ansible collection](../).
This guide shows how to use the `grafana_agent` Ansible role to deploy and manage Grafana Agent across multiple Linux hosts so you can monitor them using Grafana Cloud.
## Before you begin
Before you begin, you should have:
- Linux hosts
- SSH access to the Linux hosts
- Account permissions sufficient to install and use Grafana Agent on the Linux hosts
## Install the Grafana Ansible collection
The [`grafana_agent` role](https://github.com/grafana/grafana-ansible-collection/tree/main/roles/grafana_agent) is available in the Grafana Ansible collection as of the 1.1.0 release.
To install the Grafana Ansible collection, run this command:
```
ansible-galaxy collection install grafana.grafana
```
## Create an Ansible inventory file
Next, you will set up your hosts and create an inventory file.
1. Create your hosts and add public SSH keys to them.
This example uses eight Linux hosts: two Ubuntu hosts, two CentOS hosts, two Fedora hosts, and two Debian hosts.
1. Create an Ansible inventory file.
The Ansible inventory, which resides in a file named `inventory`, looks similar to this:
```
146.190.208.216 # hostname = ubuntu-01
146.190.208.190 # hostname = ubuntu-02
137.184.155.128 # hostname = centos-01
146.190.216.129 # hostname = centos-02
198.199.82.174 # hostname = debian-01
198.199.77.93 # hostname = debian-02
143.198.182.156 # hostname = fedora-01
143.244.174.246 # hostname = fedora-02
```
1. Create an `ansible.cfg` file within the same directory as `inventory`, with the following values:
```
[defaults]
inventory = inventory # Path to the inventory file
private_key_file = ~/.ssh/id_rsa # Path to my private SSH Key
remote_user=root # username
```
{{< admonition type="note" >}}
If you are copying the previously listed files, remove the comments (#).
{{< /admonition >}}
## Use the `grafana_agent` Ansible role
Next you will create an Ansible playbook that calls the `grafana_agent` role from the `grafana.grafana` Ansible collection.
To use the `grafana_agent` Ansible role:
1. Create a file named `deploy-agent.yml` in the same directory as `ansible.cfg` and `inventory` and add the configuration below.
```yaml
- name: Install Grafana Agent
hosts: all
become: true
vars:
grafana_cloud_api_key: <Your Cloud Access Policy token>
metrics_username: <prometheus-username> # Example - 825019
logs_username: <loki-username> # Example - 411478
prometheus_url: <prometheus-push-url> # Example - https://prometheus-us-central1.grafana.net/api/prom/push
loki_url: <loki-push-url> # Example - https://logs-prod-017.grafana.net/loki/api/v1/push
tasks:
- name: Install Grafana Agent
ansible.builtin.include_role:
name: grafana.grafana.grafana_agent
vars:
grafana_agent_metrics_config:
configs:
- name: integrations
remote_write:
- basic_auth:
password: '{{ grafana_cloud_api_key }}'
username: '{{ metrics_username }}'
url: '{{ prometheus_url }}'
global:
scrape_interval: 60s
wal_directory: /tmp/grafana-agent-wal
grafana_agent_logs_config:
configs:
- name: default
clients:
- basic_auth:
password: '{{ grafana_cloud_api_key }}'
username: '{{ logs_username }}'
url: '{{ loki_url }}'
positions:
filename: /tmp/positions.yaml
target_config:
sync_period: 10s
scrape_configs:
- job_name: varlogs
static_configs:
- targets: [localhost]
labels:
instance: ${HOSTNAME:-default}
job: varlogs
__path__: /var/log/*log
grafana_agent_integrations_config:
node_exporter:
enabled: true
instance: ${HOSTNAME:-default}
prometheus_remote_write:
- basic_auth:
password: '{{ grafana_cloud_api_key }}'
username: '{{ metrics_username }}'
url: '{{ prometheus_url }}'
grafana_agent_env_vars:
HOSTNAME: '%H'
```
The playbook calls the `grafana_agent` role from the `grafana.grafana` Ansible collection.
The Agent configuration in this playbook send metrics and logs from the Linux hosts to Grafana Cloud along with the hostname of each instance
Refer to the [Grafana Ansible documentation](https://github.com/grafana/grafana-ansible-collection/tree/main/roles/grafana_agent#role-variables) to understand the other variables you can pass to the `grafana_agent` role.
When deploying the Agent across multiple instances for monitoring them, It is essential that the Agent is able to auto-detect the hostname for ease in monitoring.
Notice that the label `instance` has been set to the value `${HOSTNAME:-default}`, which is substituted by the value of the HOSTNAME environment variable in the Linux host.
To read more about the variable substitution, refer to the Grafana Agent [node_exporter_config](/docs/grafana-cloud/send-data/agent/static/configuration/integrations/node-exporter-config/) documentation.
1. To run the playbook, run this command:
```
ansible-playbook deploy-agent.yml
```
{{< admonition type="note" >}}
You can place the `deploy-agent.yml`, `ansible.cfg` and `inventory` files in different directories based on your needs.
{{< /admonition >}}
## Check that logs and metrics are being ingested into Grafana Cloud
Logs and metrics will soon be available in Grafana Cloud.
To test this, use the Explore feature.
Click the **Explore** icon (compass icon) in the vertical navigation bar.
### Check logs
To check logs:
1. Use the drop-down menu at the top of the page to select your Loki logs data source.
1. In the log browser, run the query `{instance="centos-01"}` where `centos-01` is the hostname of one of the Linux hosts.
If you see log lines (shown in the example below), logs are being received.
{{< figure alt="Grafana Explore showing a graph and log output from the preceding query" src="/static/assets/img/blog/ansible-to-manage-agent1.png" >}}
If no log lines appear, logs aren't being collected.
### Check metrics
To check metrics:
1. Use the drop-down menu at the top of the page to select your Prometheus data source.
1. Run the query `{instance="centos-01"}` where `centos-01` is the hostname of one of the Linux hosts.
If you see a metrics graph and table (shown in the example below), metrics are being received.
{{< figure alt="Grafana Explore showing a graph and metrics table output from the preceding query" src="/static/assets/img/blog/ansible-to-manage-agent2.png" >}}
If no metrics appear, metrics aren't being collected.
### View dashboards
Now that you have logs and metrics in Grafana, you can use dashboards to view them.
Here's an example of one of the prebuilt dashboards included with the Linux integration in Grafana Cloud:
{{< figure alt="The Grafana Node Exporter integration dashboard showing panels of visualizations" src="/static/assets/img/blog/ansible-to-manage-agent3.png" >}}
Using the **Instance** drop-down in the dashboard, you can select from the hostnames where you deployed Grafana Agent and start monitoring them.
## Summary
The `grafana_agent` Ansible role makes it easy to deploy and manage Grafana Agent across multiple machines.
This example showed Grafana Agent deployments across eight Linux hosts, but it's possible to monitor more hosts using the`grafana_agent` role.
To add monitor more Linux hosts, update the `inventory` file and re-run the Ansible playbook.
To learn more about the Grafana Ansible collection, see its [GitHub repository](https://github.com/grafana/grafana-ansible-collection) or its [documentation](https://docs.ansible.com/ansible/latest/collections/grafana/grafana/index.html).

View File

@@ -5,298 +5,295 @@ keywords:
- Grafana Cloud
- Grafana Operator
- ArgoCD
title: Manage dashboards with GitOps using ArgoCD
menuTitle: Manage dashboards with ArgoCD
title: Manage Dashboards with GitOps Using ArgoCD
weight: 110
canonical: https://grafana.com/docs/grafana/latest/as-code/infrastructure-as-code/grafana-operator/manage-dashboards-argocd/
---
# Manage Grafana dashboards with GitOps using ArgoCD
# Managing Grafana Dashboards with GitOps Using ArgoCD
This guide shows you how to set up a continuous deployment pipeline using ArgoCD to synchronize your Grafana dashboards with a Git repository. You'll use the Grafana Dashboard Custom Resource provided by the Grafana Operator to manage dashboard configurations declaratively.
This guide will walk you through setting up a continuous deployment pipeline using ArgoCD to synchronize your Grafana dashboards with a Git repository. We'll use the Grafana Dashboard Custom Resource provided by the Grafana Operator to manage dashboard configurations declaratively.
## Prerequisites
Before you begin, make sure you have the following:
- An existing Grafana Cloud stack
- A Kubernetes cluster with Grafana Operator installed, as shown in [Grafana Operator Installation](/docs/grafana-cloud/as-code/infrastructure-as-code/grafana-operator/#installing-the-grafana-operator)
- ArgoCD installed on your Kubernetes cluster. Refer to the [ArgoCD Installation Guide](https://argo-cd.readthedocs.io/en/stable/getting_started/)
- A Git repository to store your dashboard configurations
- A Kubernetes cluster with Grafana Operator installed, as shown in [Grafana Operator Installation](/docs/grafana-cloud/as-code/infrastructure-as-code/grafana-operator/#installing-the-grafana-operator).
- ArgoCD installed on your Kubernetes cluster. Refer the [Installation Guide](https://argo-cd.readthedocs.io/en/stable/getting_started/).
- Git repository to store your dashboard configurations.
## Set up your Git repository
## Set Up Your Git Repository
Create a directory structure in your repository to organize your Grafana and dashboard configurations. For this tutorial, create a folder named `grafana`.
Within the repository, create a directory structure to organize your grafana and dashboard configurations. For this tutorial, lets create a folder named `grafana`.
## Set up the Grafana Operator
## Grafana Operator Setup
The Grafana Operator allows you to authenticate with the Grafana instance using the Grafana Custom Resource (CR).
The Grafana Operator allows us to authenticate with the Grafana instance using the Grafana Custom Resource (CR).
### Create the Grafana API Token Secret
1. **Create the Grafana API Token Secret:**
Store the Grafana API Token in a secret. Create a file named `grafana-token.yml` in the `grafana` folder in your Git repository:
Store the Grafana API Token in a secret with the following content in a file named `grafana-token.yml` in the `grafana` folder in your Git repo:
```yaml
apiVersion: v1
kind: Secret
metadata:
name: grafana-cloud-credentials
namespace: '<GRAFANA_OPERATOR_NAMESPACE>'
namespace: <grafana-operator-namespace>
stringData:
GRAFANA_CLOUD_INSTANCE_TOKEN: '<GRAFANA_API_KEY>'
GRAFANA_CLOUD_INSTANCE_TOKEN: <Grafana-API-Key>
type: Opaque
```
Replace the placeholders with your values:
Replace the following field values:
- _`<GRAFANA_API_KEY>`_: API key from your Grafana instance. To create an API key, refer to [Grafana API Key Documentation](/docs/grafana/latest/administration/api-keys/)
- _`<GRAFANA_OPERATOR_NAMESPACE>`_: Namespace where the `grafana-operator` is deployed in your Kubernetes cluster
- `<Grafana-API-Key>` with API key from the Grafana instance. To create an API key, refer [Grafana API Key Documentation](/docs/grafana/latest/administration/api-keys/).
- `<grafana-operator-namespace>` with the namespace where the grafana-operator is deployed in Kubernetes Cluster.
### Configure the Grafana Custom Resource
2. **Configure the Grafana Custom Resource:**
Set up the connection to your Grafana Cloud instance. Create a file named `grafana-cloud.yml` in the `grafana` folder in your Git repository:
Set up connection to your Grafana Cloud instance by creating a file named `grafana-cloud.yml` in the `grafana` folder in your Git repo with the following contents:
```yaml
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
name: '<GRAFANA_CLOUD_STACK_NAME>'
namespace: '<GRAFANA_OPERATOR_NAMESPACE>'
name: <Grafana-cloud-stack-name>
namespace: <grafana-operator-namespace>
labels:
dashboards: '<GRAFANA_CLOUD_STACK_NAME>'
dashboards: <Grafana-cloud-stack-name>
spec:
external:
url: https://<GRAFANA_CLOUD_STACK_NAME>.grafana.net/
url: https://<Grafana-cloud-stack-name>.grafana.net/
apiKey:
name: grafana-cloud-credentials
key: GRAFANA_CLOUD_INSTANCE_TOKEN
```
Replace the placeholders with your values:
Replace the following field values:
- _`<GRAFANA_CLOUD_STACK_NAME>`_: Name of your Grafana Cloud Stack
- _`<GRAFANA_OPERATOR_NAMESPACE>`_: Namespace where the `grafana-operator` is deployed in your Kubernetes cluster
- `<Grafana-API-Key>` with API key from the Grafana instance.
- `<Grafana-cloud-stack-name>` with the name of your Grafana Cloud Stack.
- `<grafana-operator-namespace>` with the namespace where the grafana-operator is deployed in Kubernetes Cluster.
## Add dashboards to your Git repository
## Add Dashboards to a Git repository
In your `grafana` directory, create a sub-folder called `dashboards`.
In your `grafana` directory, Create a sub-folder called `dashboards`. For this tutorial, we will create 3 seperate dashboards.
This guide shows you how to creates three separate dashboards. For all dashboard configurations, replace the placeholders with your values:
1. Under `dashboards` folder, Create a file named `simple-dashboard.yaml` with the following content for the first dashboard:
- _`<GRAFANA_CLOUD_STACK_NAME>`_: Name of your Grafana Cloud Stack
- _`<GRAFANA_OPERATOR_NAMESPACE>`_: Namespace where the `grafana-operator` is deployed in your Kubernetes cluster
```yaml
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: grafanadashboard-sample
namespace: <grafana-operator-namespace>
spec:
resyncPeriod: 30s
instanceSelector:
matchLabels:
dashboards: <Grafana-cloud-stack-name>
json: >
{
"id": null,
"title": "Simple Dashboard",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"graphTooltip": 1,
"panels": [],
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": [],
"refresh_intervals": []
},
"templating": {
"list": []
},
"annotations": {
"list": []
},
"refresh": "5s",
"schemaVersion": 17,
"version": 0,
"links": []
}
```
### Create a simple dashboard
Replace the following field values:
- `<Grafana-cloud-stack-name>` with the name of your Grafana Cloud Stack.
- `<grafana-operator-namespace>` with the namespace where the grafana-operator is deployed in Kubernetes Cluster.
Under the `dashboards` folder, create a file named `simple-dashboard.yaml`:
1. Under `dashboards` folder, Create a file named `dashboard-from-cm.yaml` with the following content for the second dashboard:
```yaml
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: grafanadashboard-sample
namespace: '<GRAFANA_OPERATOR_NAMESPACE>'
spec:
resyncPeriod: 30s
instanceSelector:
matchLabels:
dashboards: '<GRAFANA_CLOUD_STACK_NAME>'
json: >
{
"id": null,
"title": "Simple Dashboard",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"graphTooltip": 1,
"panels": [],
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": [],
"refresh_intervals": []
},
"templating": {
"list": []
},
"annotations": {
"list": []
},
"refresh": "5s",
"schemaVersion": 17,
"version": 0,
"links": []
}
```
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: dashboard-definition
namespace: <grafana-operator-namespace>
spec:
resyncPeriod: 30s
instanceSelector:
matchLabels:
dashboards: <Grafana-cloud-stack-name>
json: >
{
"id": null,
"title": "Simple Dashboard from ConfigMap",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"graphTooltip": 1,
"panels": [],
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": [],
"refresh_intervals": []
},
"templating": {
"list": []
},
"annotations": {
"list": []
},
"refresh": "5s",
"schemaVersion": 17,
"version": 0,
"links": []
}
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: grafanadashboard-from-configmap
namespace: <grafana-operator-namespace>
spec:
instanceSelector:
matchLabels:
dashboards: <Grafana-cloud-stack-name>
configMapRef:
name: dashboard-definition
key: json
```
### Create a dashboard from ConfigMap
Replace the following field values:
- `<Grafana-cloud-stack-name>` with the name of your Grafana Cloud Stack.
- `<grafana-operator-namespace>` with the namespace where the grafana-operator is deployed in Kubernetes Cluster.
Under the `dashboards` folder, create a file named `dashboard-from-cm.yaml`:
1. Under `dashboards` folder, Create a file named `dashboard-from-id.yaml` with the following content for the third dashboard:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: dashboard-definition
namespace: <GRAFANA_OPERATOR_NAMESPACE>
data:
json: >
{
"id": null,
"title": "Simple Dashboard from ConfigMap",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"graphTooltip": 1,
"panels": [],
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"time_options": [],
"refresh_intervals": []
},
"templating": {
"list": []
},
"annotations": {
"list": []
},
"refresh": "5s",
"schemaVersion": 17,
"version": 0,
"links": []
}
---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: grafanadashboard-from-configmap
namespace: '<GRAFANA_OPERATOR_NAMESPACE>'
spec:
instanceSelector:
matchLabels:
dashboards: '<GRAFANA_CLOUD_STACK_NAME>'
configMapRef:
name: dashboard-definition
key: json
```
```yaml
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: node-exporter-latest
namespace: <grafana-operator-namespace>
spec:
instanceSelector:
matchLabels:
dashboards: <Grafana-cloud-stack-name>
grafanaCom:
id: 1860
```
### Create a dashboard from Grafana.com
Replace the following field values:
- `<Grafana-cloud-stack-name>` with the name of your Grafana Cloud Stack.
- `<grafana-operator-namespace>` with the namespace where the grafana-operator is deployed in Kubernetes Cluster.
Under the `dashboards` folder, create a file named `dashboard-from-id.yaml`:
## Configure Argo CD to Sync the Git Repository
```yaml
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: node-exporter-latest
namespace: '<GRAFANA_OPERATOR_NAMESPACE>'
spec:
instanceSelector:
matchLabels:
dashboards: '<GRAFANA_CLOUD_STACK_NAME>'
grafanaCom:
id: 1860
```
Once all changes are committed to Git, Log in to the Argo CD user interface or use the CLI.
## Configure ArgoCD to sync the Git repository
2. Create an Argo CD application to manage the synchronization:
After you commit all changes to Git, log in to the ArgoCD user interface or use the CLI.
**Using UI**:
- Navigate to 'New App' and fill out the form with your Git repository details and the path to your `grafana` folder.
- Make sure to tick mark directory Recurse.
- Set the sync policy to `Automatic`.
### Create an ArgoCD application
**Using CLI**:
- Prepare an application manifest named `argo-application.yaml` with the configuration pointing to your Git repository:
**Using the UI:**
```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: Grafana
namespace: <argocd-namespace>
spec:
destination:
name: ''
namespace: ''
server: 'https://kubernetes.default.svc'
source:
path: <Path-to-grafana-folder>
repoURL: '<Git-repo-url>'
targetRevision: HEAD
directory:
recurse: true
sources: []
project: default
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
retry:
limit: 2
backoff:
duration: 5s
maxDuration: 3m0s
factor: 2
```
1. Navigate to **New App** and complete the form with your Git repository details and the path to your `grafana` folder
2. Enable **Directory Recurse**
3. Set the sync policy to **Automatic**
Replace the following field values:
- `<Git-repo-url>` with the URL of your GIT Repository.
- `<Path-to-grafana-folder>` with the path to the `grafana` folder.
- `<argocd-namespace>` with the namespace where ArgoCD is deployed in Kubernetes Cluster.
**Using the CLI:**
- Create the application in Argo CD:
Prepare an application manifest named `argo-application.yaml`:
```shell
kubectl apply -f argo-application.yaml
```
```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: Grafana
namespace: '<ARGOCD_NAMESPACE>'
spec:
destination:
name: ''
namespace: ''
server: 'https://kubernetes.default.svc'
source:
path: '<PATH_TO_GRAFANA_FOLDER>'
repoURL: '<GIT_REPO_URL>'
targetRevision: HEAD
directory:
recurse: true
sources: []
project: default
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
retry:
limit: 2
backoff:
duration: 5s
maxDuration: 3m0s
factor: 2
```
## Verify Sync Status in Argo CD
Replace the placeholders with your values:
1. Monitor the newly created Argo CD application, ensuring that it successfully syncs your dashboard configuration.
- _`<GIT_REPO_URL>`_: URL of your Git repository
- _`<PATH_TO_GRAFANA_FOLDER>`_: Path to the `grafana` folder in your repository
- _`<ARGOCD_NAMESPACE>`_: Namespace where ArgoCD is deployed in your Kubernetes cluster
2. Visit the Argo CD dashboard and check the sync status. If it's successful, your Grafana dashboard should be up to date with the configuration from your Git repository.
Create the application in ArgoCD:
```sh
kubectl apply -f argo-application.yaml
```
## Verify sync status in ArgoCD
1. Monitor the newly created ArgoCD application to ensure it successfully syncs your dashboard configuration
2. Visit the ArgoCD dashboard and check the sync status. If it's successful, your Grafana dashboards should be up to date with the configuration from your Git repository
## Update your dashboards
## Updating the Dashboards
To update an existing dashboard:
1. Make changes to the dashboard JSON configuration in your Git repository
2. Commit and push the changes
3. ArgoCD detects the update and synchronizes the changes to your Custom Resource
4. Grafana Operator then syncs changes to the Grafana instance
1. Make changes to the dashboard JSON configuration in your Git repository.
2. Commit and push the changes.
3. Argo CD will detect the update and synchronize the changes to your Cutom Resource.
4. Grafana Operator will then sync changes to the Grafana Instance.
### Validate your dashboard updates
## Validating the Grafana Dashboard Update
Log in to your Grafana dashboard and confirm that the changes are applied. You should see the dashboard updates reflected in the Grafana UI.
Log in to your Grafana dashboard and confirm that the changes have been applied. You should see the dashboard update reflected in the Grafana UI.
## Next steps
## Additional Tips
You've successfully set up a GitOps workflow to manage Grafana dashboards using ArgoCD and the Grafana Operator. Your dashboards are now version-controlled and can be consistently deployed across environments. This approach provides a reliable and auditable way to manage observability dashboards and scale your operations.
- You can also install the Grafana Operator's Helm Chart using ArgoCD to manage your setup with GitOps.
- You can follow a similar setup for Grafana Dashboards and Folders.
To learn more about managing Grafana using Grafana Operator:
## Conclusion
- [Grafana Operator documentation](https://grafana.github.io/grafana-operator/docs/)
- [Grafana dashboard provisioning](/docs/grafana/latest/administration/provisioning/#dashboards)
- [ArgoCD best practices](https://argo-cd.readthedocs.io/en/stable/user-guide/best_practices/)
You've set up a GitOps workflow to manage Grafana dashboards using Argo CD and the Grafana Operator. Your dashboards are now version-controlled and can be consistently deployed across environments. This approach provides a reliable and auditable way to manage observability dashboards and scale your operations.
### Additional considerations
- You can install the Grafana Operator's Helm Chart using ArgoCD to manage your setup with GitOps
- You can follow a similar setup for Grafana Folders and other resources
To learn more about managing Grafana using Grafana Operator, see the [Grafana Operator documentation](https://grafana.github.io/grafana-operator/docs/).

View File

@@ -5,27 +5,26 @@ keywords:
- Grafana Cloud
- Grafana Operator
title: Manage folders, data sources, and dashboards using Grafana Operator
menuTitle: Manage resources with the Grafana Operator
weight: 100
canonical: https://grafana.com/docs/grafana/latest/as-code/infrastructure-as-code/grafana-operator/operator-dashboards-folders-datasources/
---
# Manage folders, data sources, and dashboards using the Grafana Operator
# Creating and managing folders, data sources, and dashboards using the Grafana Operator
This guide shows you how to manage data sources, folders, and dashboards using the Grafana Operator. You'll create these resources declaratively using Kubernetes custom resources.
Learn how to manage data sources, folders and dashboard, using Grafana Operator.
## Prerequisites
Before you begin, make sure you have the following:
Before you begin, you should have the following available:
- An existing Grafana Cloud stack
- Grafana Operator installed in your cluster, as shown in [Grafana Operator Installation](/docs/grafana-cloud/as-code/infrastructure-as-code/grafana-operator/#installing-the-grafana-operator)
- An existing Grafana Cloud stack.
- Grafana Operator Installed in your Cluster, as shown in [Grafana Operator Installation](/docs/grafana-cloud/as-code/infrastructure-as-code/grafana-operator/#installing-the-grafana-operator).
## Set up the Grafana Operator
## Grafana Operator Setup
The Grafana Operator allows you to authenticate with your Grafana instance using the Grafana Custom Resource (CR).
The Grafana Operator allows us to authenticate with the Grafana instance using the Grafana Custom Resource (CR).
### Create the Grafana API Token Secret
1. **Create the Grafana API Token Secret:**
Store the Grafana API Token in a secret with the following content in a file named `grafana-token.yml`:
@@ -34,64 +33,61 @@ apiVersion: v1
kind: Secret
metadata:
name: grafana-cloud-credentials
namespace: '<GRAFANA_OPERATOR_NAMESPACE>'
namespace: <grafana-operator-namespace>
stringData:
GRAFANA_CLOUD_INSTANCE_TOKEN: '<GRAFANA_API_KEY>'
GRAFANA_CLOUD_INSTANCE_TOKEN: <Grafana-API-Key>
type: Opaque
```
Replace the placeholders with your values:
Replace the following field values:
- _`<GRAFANA_API_KEY>`_: API key from your Grafana instance. To create an API key, refer to [Grafana API Key Documentation](/docs/grafana/latest/administration/api-keys/)
- _`<GRAFANA_OPERATOR_NAMESPACE>`_: Namespace where the `grafana-operator` is deployed in your Kubernetes cluster
- `<Grafana-API-Key>` with API key from the Grafana instance. To create an API key, refer [Grafana API Key Documentation](/docs/grafana/latest/administration/api-keys/).
- `<grafana-operator-namespace>` with the namespace where the grafana-operator is deployed in Kubernetes Cluster.
### Configure the Grafana Custom Resource
2. **Configure the Grafana Custom Resource:**
Set up connection to your Grafana Cloud instance. Create a file named `grafana-cloud.yml`:
Set up connection to your Grafana Cloud instance by creating a file named `grafana-cloud.yml` with the following contents:
```yaml
apiVersion: grafana.integreatly.org/v1beta1
kind: Grafana
metadata:
name: '<GRAFANA_CLOUD_STACK_NAME>'
namespace: '<GRAFANA_OPERATOR_NAMESPACE>'
name: <Grafana-cloud-stack-name>
namespace: <grafana-operator-namespace>
labels:
dashboards: '<GRAFANA_CLOUD_STACK_NAME>'
dashboards: <Grafana-cloud-stack-name>
spec:
external:
url: https://<GRAFANA_CLOUD_STACK_NAME>.grafana.net/
url: https://<Grafana-cloud-stack-name>.grafana.net/
apiKey:
name: grafana-cloud-credentials
key: GRAFANA_CLOUD_INSTANCE_TOKEN
```
Replace the placeholders with your values:
Replace the following field values:
- _`<GRAFANA_CLOUD_STACK_NAME>`_: Name of your Grafana Cloud stack
- _`<GRAFANA_OPERATOR_NAMESPACE>`_: Namespace where the `grafana-operator` is deployed in your Kubernetes cluster
- `<Grafana-API-Key>` with API key from the Grafana instance.
- `<Grafana-cloud-stack-name>` with the name of your Grafana Cloud Stack.
- `<grafana-operator-namespace>` with the namespace where the grafana-operator is deployed in Kubernetes Cluster.
## Add a data source
{{< admonition type="note" >}}
The following steps use the Prometheus data source. The required arguments vary depending on the data source you select.
This example uses the Prometheus data source. Note that the required arguments vary depending on the data source you select.
1. **Create the Data Source Configuration:**
{{< /admonition >}}
### Create a data source configuration
Create and save a new YAML file `datasource.yml` with your data source's configuration:
Save a new YAML file `datasource.yml` with the following content:
```yaml
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDatasource
metadata:
name: '<DATA_SOURCE_NAME>'
namespace: '<GRAFANA_OPERATOR_NAMESPACE>'
name: <data-source-name>
namespace: <grafana-operator-namespace>
spec:
instanceSelector:
matchLabels:
dashboards: '<GRAFANA_CLOUD_STACK_NAME>'
dashboards: <Grafana-cloud-stack-name>
allowCrossNamespaceImport: true
datasource:
access: proxy
@@ -99,76 +95,74 @@ spec:
jsonData:
timeInterval: 5s
tlsSkipVerify: true
name: '<DATA_SOURCE_NAME>'
name: <data-source-name>
type: prometheus
url: '<DATA_SOURCE_URL>'
url: <data-source-url>
```
Replace the placeholders with your values:
Replace the following field values:
- _`<DATA_SOURCE_NAME>`_: Name of the data source to be added in Grafana
- _`<DATA_SOURCE_URL>`_: URL of your data source
- _`<GRAFANA_CLOUD_STACK_NAME>`_: Name of your Grafana Cloud stack
- _`<GRAFANA_OPERATOR_NAMESPACE>`_: Namespace where the `grafana-operator` is deployed in your Kubernetes cluster
- `<data-source-name>` with the name of the data source to be added in Grafana.
- `<data-source-url>` with URL of your data source.
- `<Grafana-cloud-stack-name>` with the name of your Grafana Cloud Stack.
- `<grafana-operator-namespace>` with the namespace where the grafana-operator is deployed in Kubernetes Cluster.
### Add a dashboard to a folder
## Add a dashboard to a folder
Use the following YAML definition to create a simple dashboard in the Grafana instance under a custom folder. If the folder defined under the `spec.folder` field doesn't exist, the operator creates it before placing the dashboard inside the folder.
Use the following YAML definition to create a simple dashboard in the Grafana instance under a custom folder. If the folder defined under spec.folder fields doesnt not exist, The operator will create it before placing the dashboard inside the folder.
Prepare the dashboard configuration. In `dashboard.yml`, define the dashboard and assign it to a folder:
1. **Prepare the Dashboard Configuration File:**
In `dashboard.yml`, define the dashboard and assign it to a folder:
```yaml
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
name: '<FOLDER_NAME>'
namespace: '<GRAFANA_OPERATOR_NAMESPACE>'
name: <folder-name>
namespace: <grafana-operator-namespace>
spec:
instanceSelector:
matchLabels:
dashboards: '<GRAFANA_CLOUD_STACK_NAME>'
folder: '<FOLDER_NAME>'
dashboards: <Grafana-cloud-stack-name>
folder: "<folder-name>"
json: >
{
"title": "as-code dashboard",
"uid" : "ascode"
}
{
"title": "as-code dashboard",
uid : ascode
}
```
Replace the placeholders with your values:
Replace the following field values:
- _`<FOLDER_NAME>`_: Name of the folder in which you want the dashboard to be created
- _`<GRAFANA_CLOUD_STACK_NAME>`_: Name of your Grafana Cloud stack
- _`<GRAFANA_OPERATOR_NAMESPACE>`_: Namespace where the `grafana-operator` is deployed in your Kubernetes cluster
- `<folder-name>` with the name of the folder in which you want the Dashboard to be created.
- `<Grafana-cloud-stack-name>` with the name of your Grafana Cloud Stack.
- `<grafana-operator-namespace>` with the namespace where the grafana-operator is deployed in Kubernetes Cluster.
## Apply the Kubernetes manifests
## Apply Kubernetes Manifests
In a terminal, run the following commands from the directory where all of the above Kubernetes YAML definitions are located.
Create Kubernetes Custom resources for all of the configurations:
1. Create Kubernetes Custom resources for all of the above configurations.
```sh
kubectl apply -f grafana-token.yml grafana-cloud.yml datasource.yml dashboard.yml
```
```shell
kubectl apply -f grafana-token.yml grafana-cloud.yml datasource.yml dashboard.yml
```
## Validate your configuration
## Validation
After you apply the configurations, verify that:
Once you apply the configurations, you should be able to verify the following:
- A new data source is visible in Grafana. In the following image, a data source named `InfluxDB` was created.
- A new data source is visible in Grafana. In the following image a datasource named `InfluxDB` was created.
![InfluxDB datasource](/static/img/docs/grafana-cloud/terraform/influxdb_datasource_tf.png)
- A new dashboard and folder have been created in Grafana. In the following image, a dashboard named `InfluxDB Cloud Demos` was created inside the `Demos` folder.
- A new dashboard and folder in Grafana. In the following image a dashboard named `InfluxDB Cloud Demos` was created inside the `Demos` folder.
![InfluxDB dashboard](/static/img/docs/grafana-cloud/grizzly/grizzly-folder-dashboard-datasource.png)
## Next steps
## Conclusion
You've successfully created a data source, folder, and dashboard using the Grafana Operator. Your Grafana resources are now managed declaratively through Kubernetes custom resources.
In this guide, you created a data source, folder, and dashboard using the Grafana Operator.
To learn more about managing Grafana:
- [Grafana Operator documentation](https://grafana.github.io/grafana-operator/docs/)
- [Grafana dashboard provisioning](/docs/grafana/latest/administration/provisioning/#dashboards)
- [Grafana data source provisioning](/docs/grafana/latest/administration/provisioning/#data-sources)
To learn more about managing Grafana using Grafana Operator, see the [Grafana Operator documentation](https://grafana.github.io/grafana-operator/docs/).

View File

@@ -13,7 +13,7 @@ labels:
- enterprise
- oss
title: JSON schema v2
weight: 500
weight: 200
canonical: https://grafana.com/docs/grafana/latest/as-code/observability-as-code/schema-v2/
aliases:
- ../../observability-as-code/schema-v2/ # /docs/grafana/next/observability-as-code/schema-v2/

View File

@@ -213,7 +213,7 @@ role_attribute_path = [login=='octocat'][0] && 'GrafanaAdmin' || 'Viewer'
## Configure team synchronization
{{< admonition type="note" >}}
Available in [Grafana Enterprise](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/) and [Grafana Cloud](https://grafana.com/products/cloud/)
Available in [Grafana Enterprise](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/) and to customers on select Grafana Cloud plans. For pricing information, visit [pricing](https://grafana.com/pricing/) or contact our sales team.
{{< /admonition >}}
By using Team Sync, you can map teams from your GitHub organization to teams within Grafana. This will automatically assign users to the appropriate teams.

View File

@@ -238,7 +238,7 @@ use_refresh_token = true
## Configure team synchronization
{{< admonition type="note" >}}
Available in [Grafana Enterprise](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/) and [Grafana Cloud](https://grafana.com/products/cloud/)
Available in [Grafana Enterprise](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/) and to customers on select Grafana Cloud plans. For pricing information, visit [pricing](https://grafana.com/pricing/) or contact our sales team.
{{< /admonition >}}
By using Team Sync, you can map GitLab groups to teams within Grafana. This will automatically assign users to the appropriate teams.

View File

@@ -162,7 +162,7 @@ auto_login = true
### Configure team synchronization
{{< admonition type="note" >}}
Available in [Grafana Enterprise](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/) and [Grafana Cloud](https://grafana.com/products/cloud/).
Available in [Grafana Enterprise](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/) and to customers on select Grafana Cloud plans. For pricing information, visit [pricing](https://grafana.com/pricing/) or contact our sales team.
{{< /admonition >}}
With team sync, you can easily add users to teams by utilizing their Google groups. To set up team sync for Google OAuth, refer to the following example.

View File

@@ -111,7 +111,7 @@ viewer
## Team sync
{{< admonition type="note" >}}
Available in [Grafana Enterprise](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/) and [Grafana Cloud](https://grafana.com/products/cloud/).
Available in [Grafana Enterprise](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/) and to customers on select Grafana Cloud plans. For pricing information, visit [pricing](https://grafana.com/pricing/) or contact our sales team.
{{< /admonition >}}
[Team Sync](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-access/configure-team-sync/) is a feature that allows you to map groups from your identity provider to Grafana teams. This is useful if you want to give your users access to specific dashboards or folders based on their group membership.

View File

@@ -238,7 +238,7 @@ org_mapping = ["Group 1:org_foo:Viewer", "Group 2:org_bar:Editor", "*:3:Editor"]
### Configure team synchronization
{{< admonition type="note" >}}
Available in [Grafana Enterprise](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/) and [Grafana Cloud](https://grafana.com/products/cloud/).
Available in [Grafana Enterprise](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/) and to customers on select Grafana Cloud plans. For pricing information, visit [pricing](https://grafana.com/pricing/) or contact our sales team.
{{< /admonition >}}
By using Team Sync, you can link your Okta groups to teams within Grafana. This will automatically assign users to the appropriate teams.

View File

@@ -18,7 +18,7 @@ weight: 600
Team sync lets you set up synchronization between your auth providers teams and teams in Grafana. This enables LDAP, OAuth, or SAML users who are members of certain teams or groups to automatically be added or removed as members of certain teams in Grafana.
{{< admonition type="note" >}}
Available in [Grafana Enterprise](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/) and [Grafana Cloud](https://grafana.com/docs/grafana-cloud/).
Available in [Grafana Enterprise](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/) and [Grafana Cloud Advanced](https://grafana.com/docs/grafana-cloud/).
{{< /admonition >}}
Grafana keeps track of all synchronized users in teams, and you can see which users have been synchronized in the team members list, see `LDAP` label in screenshot.

View File

@@ -190,10 +190,6 @@ Name of the TrueType font file with bold style.
Name of the TrueType font file with italic style. Default is `DejaVuSansCondensed-Oblique.ttf`.
### font_min_text_size
The minimum pixel size that Grafana uses when rendering fonts. Default is `4`.
### max_retries_per_panel
Maximum number of times the following reporting rendering requests are retried before returning an error: generating PDFs, generating embedded dashboard images for report emails, and generating attached CSV files. To disable the retry feature, enter `0`. This is available in public preview and requires the `reportingRetries` feature toggle. Default is `3`.

View File

@@ -41,6 +41,7 @@ Most [generally available](https://grafana.com/docs/release-life-cycle/#general-
| `dashboardSceneForViewers` | Enables dashboard rendering using Scenes for viewer roles | Yes |
| `dashboardSceneSolo` | Enables rendering dashboards using scenes for solo panels | Yes |
| `dashboardScene` | Enables dashboard rendering using scenes for all roles | Yes |
| `logsInfiniteScrolling` | Enables infinite scrolling for the Logs panel in Explore and Dashboards | Yes |
| `alertingQueryOptimization` | Optimizes eligible queries in order to reduce load on datasources | |
| `onPremToCloudMigrations` | Enable the Grafana Migration Assistant, which helps you easily migrate various on-prem resources to your Grafana Cloud stack. | Yes |
| `cloudWatchNewLabelParsing` | Updates CloudWatch label parsing to be more accurate | Yes |
@@ -89,7 +90,6 @@ Most [generally available](https://grafana.com/docs/release-life-cycle/#general-
| `alertingSaveStateCompressed` | Enables the compressed protobuf-based alert state storage. Default is enabled. |
| `sqlExpressions` | Enables SQL Expressions, which can execute SQL queries against data source results. |
| `queryLibrary` | Enables Saved queries (query library) feature |
| `dashboardTemplates` | Enables a flow to get started with a new dashboard from a template |
| `enableSCIM` | Enables SCIM support for user and group management |
| `alertRuleRestore` | Enables the alert rule restore feature |
| `azureMonitorLogsBuilderEditor` | Enables the logs builder mode for the Azure Monitor data source |

View File

@@ -0,0 +1,617 @@
---
aliases:
- ../administration/image_rendering/
- ../image-rendering/
description: Image rendering
keywords:
- grafana
- image
- rendering
- plugin
labels:
products:
- enterprise
- oss
title: Set up image rendering
weight: 1000
---
# Set up image rendering
Grafana supports automatic rendering of panels as PNG images. This allows Grafana to automatically generate images of your panels to include in alert notifications, [PDF export](../../dashboards/create-reports/#export-dashboard-as-pdf), and [Reporting](../../dashboards/create-reports/). PDF Export and Reporting are available only in [Grafana Enterprise](../../introduction/grafana-enterprise/) and [Grafana Cloud](/docs/grafana-cloud/).
While an image is being rendered, the PNG image is temporarily written to the file system. When the image is rendered, the PNG image is temporarily written to the `png` folder in the Grafana `data` folder.
A background job runs every 10 minutes and removes temporary images. You can configure how long an image should be stored before being removed by configuring the [temp_data_lifetime](../configure-grafana/#temp_data_lifetime) setting.
You can also render a PNG by hovering over the panel to display the actions menu in the top-right corner, and then clicking **Share > Share link**. The **Render image** option is displayed in the link settings.
## Alerting and render limits
Alert notifications can include images, but rendering many images at the same time can overload the server where the renderer is running. For instructions of how to configure this, see [max_concurrent_screenshots](../configure-grafana/#max_concurrent_screenshots).
## Install Grafana Image Renderer plugin
{{< admonition type="caution" >}}
Starting with Grafana v12.2, the Grafana Image Renderer plugin is deprecated and is no longer maintained.
Instead, use the Grafana Image Renderer remote rendering service.
{{< /admonition >}}
{{< admonition type="note" >}}
All PhantomJS support has been removed. Instead, use the Grafana Image Renderer plugin or remote rendering service.
{{< /admonition >}}
To install the plugin, refer to the [Grafana Image Renderer Installation instructions](/grafana/plugins/grafana-image-renderer/?tab=installation#installation).
### Memory requirements
Rendering images requires a lot of memory, mainly because Grafana creates browser instances in the background for the actual rendering. Grafana recommends a minimum of 16GB of free memory on the system rendering images.
Rendering multiple images in parallel requires an even bigger memory footprint. You can use the remote rendering service in order to render images on a remote system, so your local system resources are not affected.
## Configuration
The Grafana Image Renderer plugin has a number of configuration options that are used in plugin or remote rendering modes.
In plugin mode, you can specify them directly in the [Grafana configuration file](../configure-grafana/#plugingrafana-image-renderer).
In remote rendering mode, you can specify them in a `.json` [configuration file](#configuration-file) or, for some of them, you can override the configuration defaults using environment variables.
### Configuration file
You can update your settings by using a configuration file, see [default.json](https://github.com/grafana/grafana-image-renderer/tree/master/default.json) for defaults. Note that any configured environment variable takes precedence over configuration file settings.
You can volume mount your custom configuration file when starting the docker container:
```bash
docker run -d --name=renderer --network=host -v /some/path/config.json:/home/nonroot/config.json grafana/grafana-image-renderer:latest
```
You can see a docker-compose example using a custom configuration file [here](https://github.com/grafana/grafana-image-renderer/tree/master/devenv/docker/custom-config).
{{< admonition type="note" >}}
The configuration files were located in `/usr/src/app` up until v4.0.0 and later.
After this point, they are located in `/home/nonroot`.
{{< /admonition >}}
### Security
{{< admonition type="note" >}}
This feature is available in Image Renderer v3.6.1 and later.
{{< /admonition >}}
You can restrict access to the rendering endpoint by specifying a secret token. The token should be configured in the Grafana configuration file and the renderer configuration file. This token is important when you run the plugin in remote rendering mode.
Renderer versions v3.6.1 or later require a Grafana version with this feature. These include:
- Grafana v9.1.2 or later
- Grafana v9.0.8 or later patch releases
- Grafana v8.5.11 or later patch releases
- Grafana v8.4.11 or later patch releases
- Grafana v8.3.11 or later patch releases
```bash
AUTH_TOKEN=-
```
```json
{
"service": {
"security": {
"authToken": "-"
}
}
}
```
See [Grafana configuration](../configure-grafana/#renderer_token) for how to configure the token in Grafana.
### Rendering mode
You can instruct how headless browser instances are created by configuring a rendering mode. Default is `default`, other supported values are `clustered` and `reusable`.
#### Default
Default mode will create a new browser instance on each request. When handling multiple concurrent requests, this mode increases memory usage as it will launch multiple browsers at the same time. If you want to set a maximum number of browser to open, you'll need to use the [clustered mode](#clustered).
{{< admonition type="note" >}}
When using the `default` mode, it's recommended to not remove the default Chromium flag `--disable-gpu`. When receiving a lot of concurrent requests, not using this flag can cause Puppeteer `newPage` function to freeze, causing request timeouts and leaving browsers open.
{{< /admonition >}}
```bash
RENDERING_MODE=default
```
```json
{
"rendering": {
"mode": "default"
}
}
```
#### Clustered
With the `clustered` mode, you can configure how many browser instances or incognito pages can execute concurrently. Default is `browser` and will ensure a maximum amount of browser instances can execute concurrently. Mode `context` will ensure a maximum amount of incognito pages can execute concurrently. You can also configure the maximum concurrency allowed, which per default is `5`, and the maximum duration of a rendering request, which per default is `30` seconds.
Using a cluster of incognito pages is more performant and consumes less CPU and memory than a cluster of browsers. However, if one page crashes it can bring down the entire browser with it (making all the rendering requests happening at the same time fail). Also, each page isn't guaranteed to be totally clean (cookies and storage might bleed-through as seen [here](https://bugs.chromium.org/p/chromium/issues/detail?id=754576)).
```bash
RENDERING_MODE=clustered
RENDERING_CLUSTERING_MODE=browser
RENDERING_CLUSTERING_MAX_CONCURRENCY=5
RENDERING_CLUSTERING_TIMEOUT=30
```
```json
{
"rendering": {
"mode": "clustered",
"clustering": {
"mode": "browser",
"maxConcurrency": 5,
"timeout": 30
}
}
}
```
#### Reusable (experimental)
When using the rendering mode `reusable`, one browser instance will be created and reused. A new incognito page will be opened for each request. This mode is experimental since, if the browser instance crashes, it will not automatically be restarted. You can achieve a similar behavior using `clustered` mode with a high `maxConcurrency` setting.
```bash
RENDERING_MODE=reusable
```
```json
{
"rendering": {
"mode": "reusable"
}
}
```
#### Optimize the performance, CPU and memory usage of the image renderer
The performance and resources consumption of the different modes depend a lot on the number of concurrent requests your service is handling. To understand how many concurrent requests your service is handling, [monitor your image renderer service](monitoring/).
With no concurrent requests, the different modes show very similar performance and CPU / memory usage.
When handling concurrent requests, we see the following trends:
- To improve performance and reduce CPU and memory consumption, use [clustered](#clustered) mode with `RENDERING_CLUSTERING_MODE` set as `context`. This parallelizes incognito pages instead of browsers.
- If you use the [clustered](#clustered) mode with a `maxConcurrency` setting below your average number of concurrent requests, performance will drop as the rendering requests will need to wait for the other to finish before getting access to an incognito page / browser.
To achieve better performance, monitor the machine on which your service is running. If you don't have enough memory and / or CPU, every rendering step will be slower than usual, increasing the duration of every rendering request.
### Other available settings
{{< admonition type="note" >}}
Please note that not all settings are available using environment variables. If there is no example using environment variable below, it means that you need to update the configuration file.
{{< /admonition >}}
#### HTTP host
Change the listening host of the HTTP server. Default is unset and will use the local host.
```bash
HTTP_HOST=localhost
```
```json
{
"service": {
"host": "localhost"
}
}
```
#### HTTP port
Change the listening port of the HTTP server. Default is `8081`. Setting `0` will automatically assign a port not in use.
```bash
HTTP_PORT=0
```
```json
{
"service": {
"port": 0
}
}
```
#### HTTP protocol
{{< admonition type="note" >}}
HTTPS protocol is supported in the image renderer v3.11.0 and later.
{{< /admonition >}}
Change the protocol of the server, it can be `http` or `https`. Default is `http`.
```bash
HTTP_PROTOCOL=https
```
```json
{
"service": {
"protocol": "https"
}
}
```
#### HTTPS certificate and key file
Path to the image renderer certificate and key file used to start an HTTPS server.
```bash
HTTP_CERT_FILE=./path/to/cert
HTTP_CERT_KEY=./path/to/key
```
```json
{
"service": {
"certFile": "./path/to/cert",
"certKey": "./path/to/key"
}
}
```
#### HTTPS min TLS version
Minimum TLS version allowed. Accepted values are: `TLSv1.2`, `TLSv1.3`. Default is `TLSv1.2`.
```bash
HTTP_MIN_TLS_VERSION=TLSv1.2
```
```json
{
"service": {
"minTLSVersion": "TLSv1.2"
}
}
```
#### Enable Prometheus metrics
You can enable [Prometheus](https://prometheus.io/) metrics endpoint `/metrics` using the environment variable `ENABLE_METRICS`. Node.js and render request duration metrics are included, see [Enable Prometheus metrics endpoint](monitoring/#enable-prometheus-metrics-endpoint) for details.
Default is `false`.
```bash
ENABLE_METRICS=true
```
```json
{
"service": {
"metrics": {
"enabled": true,
"collectDefaultMetrics": true,
"requestDurationBuckets": [1, 5, 7, 9, 11, 13, 15, 20, 30]
}
}
}
```
#### Enable detailed timing metrics
With the [Prometheus metrics enabled](#enable-prometheus-metrics), you can also enable detailed metrics to get the duration of every rendering step.
Default is `false`.
```bash
# Available from v3.9.0+
RENDERING_TIMING_METRICS=true
```
```json
{
"rendering": {
"timingMetrics": true
}
}
```
#### Log level
Change the log level. Default is `info` and will include log messages with level `error`, `warning` and `info`.
```bash
LOG_LEVEL=debug
```
```json
{
"service": {
"logging": {
"level": "debug",
"console": {
"json": false,
"colorize": true
}
}
}
}
```
#### Verbose logging
Instruct headless browser instance whether to capture and log verbose information when rendering an image. Default is `false` and will only capture and log error messages. When enabled (`true`) debug messages are captured and logged as well.
Note that you need to change log level to `debug`, see above, for the verbose information to be included in the logs.
```bash
RENDERING_VERBOSE_LOGGING=true
```
```json
{
"rendering": {
"verboseLogging": true
}
}
```
#### Capture browser output
Instruct headless browser instance whether to output its debug and error messages into running process of remote rendering service. Default is `false`.
This can be useful to enable (`true`) when troubleshooting.
```bash
RENDERING_DUMPIO=true
```
```json
{
"rendering": {
"dumpio": true
}
}
```
#### Tracing
{{< admonition type="note" >}}
Tracing is supported in the image renderer v3.12.6 and later.
{{< /admonition >}}
Set the tracing URL to enable OpenTelemetry Tracing. The default is empty (disabled).
You can also configure the service name that will be set in the traces. The default is `grafana-image-renderer`.
```bash
RENDERING_TRACING_URL="http://localhost:4318/v1/traces"
```
```json
{
"rendering": {
"tracing": {
"url": "http://localhost:4318/v1/traces",
"serviceName": "grafana-renderer"
}
}
}
```
#### Custom Chrome/Chromium
If you already have [Chrome](https://www.google.com/chrome/) or [Chromium](https://www.chromium.org/)
installed on your system, then you can use this instead of the pre-packaged version of Chromium.
{{< admonition type="note" >}}
Please note that this is not recommended, since you may encounter problems if the installed version of Chrome/Chromium is not compatible with the [Grafana Image renderer plugin](/grafana/plugins/grafana-image-renderer).
{{< /admonition >}}
You need to make sure that the Chrome/Chromium executable is available for the Grafana/image rendering service process.
```bash
CHROME_BIN="/usr/bin/chromium-browser"
```
```json
{
"rendering": {
"chromeBin": "/usr/bin/chromium-browser"
}
}
```
#### Start browser with additional arguments
Additional arguments to pass to the headless browser instance. Defaults are `--no-sandbox,--disable-gpu`. The list of Chromium flags can be found [here](https://peter.sh/experiments/chromium-command-line-switches/) and the list of flags used as defaults by Puppeteer can be found [there](https://cri.dev/posts/2020-04-04-Full-list-of-Chromium-Puppeteer-flags/). Multiple arguments is separated with comma-character.
```bash
RENDERING_ARGS=--no-sandbox,--disable-setuid-sandbox,--disable-dev-shm-usage,--disable-accelerated-2d-canvas,--disable-gpu,--window-size=1280x758
```
```json
{
"rendering": {
"args": [
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-dev-shm-usage",
"--disable-accelerated-2d-canvas",
"--disable-gpu",
"--window-size=1280x758"
]
}
}
```
#### Ignore HTTPS errors
Instruct headless browser instance whether to ignore HTTPS errors during navigation. Per default HTTPS errors are not ignored.
Due to the security risk it's not recommended to ignore HTTPS errors.
```bash
IGNORE_HTTPS_ERRORS=true
```
```json
{
"rendering": {
"ignoresHttpsErrors": true
}
}
```
#### Default timezone
Instruct headless browser instance to use a default timezone when not provided by Grafana, .e.g. when rendering panel image of alert. See [ICUs metaZones.txt](https://cs.chromium.org/chromium/src/third_party/icu/source/data/misc/metaZones.txt?rcl=faee8bc70570192d82d2978a71e2a615788597d1) for a list of supported timezone IDs. Fallbacks to `TZ` environment variable if not set.
```bash
BROWSER_TZ=Europe/Stockholm
```
```json
{
"rendering": {
"timezone": "Europe/Stockholm"
}
}
```
#### Default language
Instruct headless browser instance to use a default language when not provided by Grafana, e.g. when rendering panel image of alert.
Refer to the HTTP header Accept-Language to understand how to format this value.
```bash
# Available from v3.9.0+
RENDERING_LANGUAGE="fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5"
```
```json
{
"rendering": {
"acceptLanguage": "fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5"
}
}
```
#### Viewport width
Default viewport width when width is not specified in the rendering request. Default is `1000`.
```bash
# Available from v3.9.0+
RENDERING_VIEWPORT_WIDTH=1000
```
```json
{
"rendering": {
"width": 1000
}
}
```
#### Viewport height
Default viewport height when height is not specified in the rendering request. Default is `500`.
```bash
# Available from v3.9.0+
RENDERING_VIEWPORT_HEIGHT=500
```
```json
{
"rendering": {
"height": 500
}
}
```
#### Viewport maximum width
Limit the maximum viewport width that can be requested. Default is `3000`.
```bash
# Available from v3.9.0+
RENDERING_VIEWPORT_MAX_WIDTH=1000
```
```json
{
"rendering": {
"maxWidth": 1000
}
}
```
#### Viewport maximum height
Limit the maximum viewport height that can be requested. Default is `3000`.
```bash
# Available from v3.9.0+
RENDERING_VIEWPORT_MAX_HEIGHT=500
```
```json
{
"rendering": {
"maxHeight": 500
}
}
```
#### Device scale factor
Specify default device scale factor for rendering images. `2` is enough for monitor resolutions, `4` would be better for printed material. Setting a higher value affects performance and memory. Default is `1`.
This can be overridden in the rendering request.
```bash
# Available from v3.9.0+
RENDERING_VIEWPORT_DEVICE_SCALE_FACTOR=2
```
```json
{
"rendering": {
"deviceScaleFactor": 2
}
}
```
#### Maximum device scale factor
Limit the maximum device scale factor that can be requested. Default is `4`.
```bash
# Available from v3.9.0+
RENDERING_VIEWPORT_MAX_DEVICE_SCALE_FACTOR=4
```
```json
{
"rendering": {
"maxDeviceScaleFactor": 4
}
}
```
#### Page zoom level
The following command sets a page zoom level. The default value is `1`. A value of `1.5` equals 150% zoom.
```bash
RENDERING_VIEWPORT_PAGE_ZOOM_LEVEL=1
```
```json
{
"rendering": {
"pageZoomLevel": 1
}
}
```

View File

@@ -0,0 +1,221 @@
---
aliases:
- ../../image-rendering/monitoring/
description: Image rendering monitoring
keywords:
- grafana
- image
- rendering
- plugin
- monitoring
labels:
products:
- enterprise
- oss
title: Monitor the image renderer
weight: 100
---
# Monitor the image renderer
Rendering images requires a lot of memory, mainly because Grafana creates browser instances in the background for the actual rendering. Monitoring your service can help you allocate the right amount of resources to your rendering service and set the right [rendering mode](../#rendering-mode).
## Enable Prometheus metrics endpoint
Configure this service to expose a Prometheus metrics endpoint. For information on how to configure and monitor this service using Prometheus as a data source, refer to [Grafana Image Rendering Service dashboard](/grafana/dashboards/12203).
**Metrics endpoint output example:**
```
# HELP process_cpu_user_seconds_total Total user CPU time spent in seconds.
# TYPE process_cpu_user_seconds_total counter
process_cpu_user_seconds_total 0.536 1579444523566
# HELP process_cpu_system_seconds_total Total system CPU time spent in seconds.
# TYPE process_cpu_system_seconds_total counter
process_cpu_system_seconds_total 0.064 1579444523566
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.6000000000000001 1579444523566
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1579444433
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 52686848 1579444523568
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 2055344128 1579444523568
# HELP process_heap_bytes Process heap size in bytes.
# TYPE process_heap_bytes gauge
process_heap_bytes 1996390400 1579444523568
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 31 1579444523567
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1573877
# HELP nodejs_eventloop_lag_seconds Lag of event loop in seconds.
# TYPE nodejs_eventloop_lag_seconds gauge
nodejs_eventloop_lag_seconds 0.000915922 1579444523567
# HELP nodejs_active_handles Number of active libuv handles grouped by handle type. Every handle type is C++ class name.
# TYPE nodejs_active_handles gauge
nodejs_active_handles{type="WriteStream"} 2 1579444523566
nodejs_active_handles{type="Server"} 1 1579444523566
nodejs_active_handles{type="Socket"} 9 1579444523566
nodejs_active_handles{type="ChildProcess"} 2 1579444523566
# HELP nodejs_active_handles_total Total number of active handles.
# TYPE nodejs_active_handles_total gauge
nodejs_active_handles_total 14 1579444523567
# HELP nodejs_active_requests Number of active libuv requests grouped by request type. Every request type is C++ class name.
# TYPE nodejs_active_requests gauge
nodejs_active_requests{type="FSReqCallback"} 2
# HELP nodejs_active_requests_total Total number of active requests.
# TYPE nodejs_active_requests_total gauge
nodejs_active_requests_total 2 1579444523567
# HELP nodejs_heap_size_total_bytes Process heap size from node.js in bytes.
# TYPE nodejs_heap_size_total_bytes gauge
nodejs_heap_size_total_bytes 13725696 1579444523567
# HELP nodejs_heap_size_used_bytes Process heap size used from node.js in bytes.
# TYPE nodejs_heap_size_used_bytes gauge
nodejs_heap_size_used_bytes 12068008 1579444523567
# HELP nodejs_external_memory_bytes Nodejs external memory size in bytes.
# TYPE nodejs_external_memory_bytes gauge
nodejs_external_memory_bytes 1728962 1579444523567
# HELP nodejs_heap_space_size_total_bytes Process heap space size total from node.js in bytes.
# TYPE nodejs_heap_space_size_total_bytes gauge
nodejs_heap_space_size_total_bytes{space="read_only"} 262144 1579444523567
nodejs_heap_space_size_total_bytes{space="new"} 1048576 1579444523567
nodejs_heap_space_size_total_bytes{space="old"} 9809920 1579444523567
nodejs_heap_space_size_total_bytes{space="code"} 425984 1579444523567
nodejs_heap_space_size_total_bytes{space="map"} 1052672 1579444523567
nodejs_heap_space_size_total_bytes{space="large_object"} 1077248 1579444523567
nodejs_heap_space_size_total_bytes{space="code_large_object"} 49152 1579444523567
nodejs_heap_space_size_total_bytes{space="new_large_object"} 0 1579444523567
# HELP nodejs_heap_space_size_used_bytes Process heap space size used from node.js in bytes.
# TYPE nodejs_heap_space_size_used_bytes gauge
nodejs_heap_space_size_used_bytes{space="read_only"} 32296 1579444523567
nodejs_heap_space_size_used_bytes{space="new"} 601696 1579444523567
nodejs_heap_space_size_used_bytes{space="old"} 9376600 1579444523567
nodejs_heap_space_size_used_bytes{space="code"} 286688 1579444523567
nodejs_heap_space_size_used_bytes{space="map"} 704320 1579444523567
nodejs_heap_space_size_used_bytes{space="large_object"} 1064872 1579444523567
nodejs_heap_space_size_used_bytes{space="code_large_object"} 3552 1579444523567
nodejs_heap_space_size_used_bytes{space="new_large_object"} 0 1579444523567
# HELP nodejs_heap_space_size_available_bytes Process heap space size available from node.js in bytes.
# TYPE nodejs_heap_space_size_available_bytes gauge
nodejs_heap_space_size_available_bytes{space="read_only"} 229576 1579444523567
nodejs_heap_space_size_available_bytes{space="new"} 445792 1579444523567
nodejs_heap_space_size_available_bytes{space="old"} 417712 1579444523567
nodejs_heap_space_size_available_bytes{space="code"} 20576 1579444523567
nodejs_heap_space_size_available_bytes{space="map"} 343632 1579444523567
nodejs_heap_space_size_available_bytes{space="large_object"} 0 1579444523567
nodejs_heap_space_size_available_bytes{space="code_large_object"} 0 1579444523567
nodejs_heap_space_size_available_bytes{space="new_large_object"} 1047488 1579444523567
# HELP nodejs_version_info Node.js version info.
# TYPE nodejs_version_info gauge
nodejs_version_info{version="v14.16.1",major="14",minor="16",patch="1"} 1
# HELP grafana_image_renderer_service_http_request_duration_seconds duration histogram of http responses labeled with: status_code
# TYPE grafana_image_renderer_service_http_request_duration_seconds histogram
grafana_image_renderer_service_http_request_duration_seconds_bucket{le="1",status_code="200"} 0
grafana_image_renderer_service_http_request_duration_seconds_bucket{le="5",status_code="200"} 4
grafana_image_renderer_service_http_request_duration_seconds_bucket{le="7",status_code="200"} 4
grafana_image_renderer_service_http_request_duration_seconds_bucket{le="9",status_code="200"} 4
grafana_image_renderer_service_http_request_duration_seconds_bucket{le="11",status_code="200"} 4
grafana_image_renderer_service_http_request_duration_seconds_bucket{le="13",status_code="200"} 4
grafana_image_renderer_service_http_request_duration_seconds_bucket{le="15",status_code="200"} 4
grafana_image_renderer_service_http_request_duration_seconds_bucket{le="20",status_code="200"} 4
grafana_image_renderer_service_http_request_duration_seconds_bucket{le="30",status_code="200"} 4
grafana_image_renderer_service_http_request_duration_seconds_bucket{le="+Inf",status_code="200"} 4
grafana_image_renderer_service_http_request_duration_seconds_sum{status_code="200"} 10.492873834
grafana_image_renderer_service_http_request_duration_seconds_count{status_code="200"} 4
# HELP up 1 = up, 0 = not up
# TYPE up gauge
up 1
# HELP grafana_image_renderer_http_request_in_flight A gauge of requests currently being served by the image renderer.
# TYPE grafana_image_renderer_http_request_in_flight gauge
grafana_image_renderer_http_request_in_flight 1
# HELP grafana_image_renderer_step_duration_seconds duration histogram of browser steps for rendering an image labeled with: step
# TYPE grafana_image_renderer_step_duration_seconds histogram
grafana_image_renderer_step_duration_seconds_bucket{le="0.3",step="launch"} 0
grafana_image_renderer_step_duration_seconds_bucket{le="0.5",step="launch"} 0
grafana_image_renderer_step_duration_seconds_bucket{le="1",step="launch"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="2",step="launch"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="3",step="launch"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="5",step="launch"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="+Inf",step="launch"} 1
grafana_image_renderer_step_duration_seconds_sum{step="launch"} 0.7914972
grafana_image_renderer_step_duration_seconds_count{step="launch"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="0.3",step="newPage"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="0.5",step="newPage"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="1",step="newPage"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="2",step="newPage"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="3",step="newPage"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="5",step="newPage"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="+Inf",step="newPage"} 1
grafana_image_renderer_step_duration_seconds_sum{step="newPage"} 0.2217868
grafana_image_renderer_step_duration_seconds_count{step="newPage"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="0.3",step="prepare"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="0.5",step="prepare"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="1",step="prepare"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="2",step="prepare"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="3",step="prepare"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="5",step="prepare"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="+Inf",step="prepare"} 1
grafana_image_renderer_step_duration_seconds_sum{step="prepare"} 0.0819274
grafana_image_renderer_step_duration_seconds_count{step="prepare"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="0.3",step="navigate"} 0
grafana_image_renderer_step_duration_seconds_bucket{le="0.5",step="navigate"} 0
grafana_image_renderer_step_duration_seconds_bucket{le="1",step="navigate"} 0
grafana_image_renderer_step_duration_seconds_bucket{le="2",step="navigate"} 0
grafana_image_renderer_step_duration_seconds_bucket{le="3",step="navigate"} 0
grafana_image_renderer_step_duration_seconds_bucket{le="5",step="navigate"} 0
grafana_image_renderer_step_duration_seconds_bucket{le="+Inf",step="navigate"} 1
grafana_image_renderer_step_duration_seconds_sum{step="navigate"} 15.3311258
grafana_image_renderer_step_duration_seconds_count{step="navigate"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="0.3",step="panelsRendered"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="0.5",step="panelsRendered"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="1",step="panelsRendered"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="2",step="panelsRendered"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="3",step="panelsRendered"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="5",step="panelsRendered"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="+Inf",step="panelsRendered"} 1
grafana_image_renderer_step_duration_seconds_sum{step="panelsRendered"} 0.0205577
grafana_image_renderer_step_duration_seconds_count{step="panelsRendered"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="0.3",step="screenshot"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="0.5",step="screenshot"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="1",step="screenshot"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="2",step="screenshot"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="3",step="screenshot"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="5",step="screenshot"} 1
grafana_image_renderer_step_duration_seconds_bucket{le="+Inf",step="screenshot"} 1
grafana_image_renderer_step_duration_seconds_sum{step="screenshot"} 0.2866623
grafana_image_renderer_step_duration_seconds_count{step="screenshot"} 1
# HELP grafana_image_renderer_browser_info A metric with a constant '1 value labeled by version of the browser in use
# TYPE grafana_image_renderer_browser_info gauge
grafana_image_renderer_browser_info{version="HeadlessChrome/79.0.3945.0"} 1
```

View File

@@ -0,0 +1,156 @@
---
aliases:
- ../../image-rendering/troubleshooting/
description: Image rendering troubleshooting
keywords:
- grafana
- image
- rendering
- plugin
- troubleshooting
labels:
products:
- enterprise
- oss
menuTitle: Troubleshooting
title: Troubleshoot image rendering
weight: 200
---
# Troubleshoot image rendering
In this section, you'll learn how to enable logging for the image renderer and you'll find the most common issues.
## Enable debug logging
To troubleshoot the image renderer, different kind of logs are available.
You can enable debug log messages for rendering in the Grafana configuration file and inspect the Grafana server logs.
```bash
[log]
filters = rendering:debug
```
You can also enable more logs in image renderer service itself by enabling [debug logging](#enable-debug-logging).
## Missing libraries
The plugin and rendering service uses [Chromium browser](https://www.chromium.org/) which depends on certain libraries.
If you don't have all of those libraries installed in your system you may encounter errors when trying to render an image, e.g.
```bash
Rendering failed: Error: Failed to launch chrome!/var/lib/grafana/plugins/grafana-image-renderer/chrome-linux/chrome:
error while loading shared libraries: libX11.so.6: cannot open shared object file: No such file or directory\n\n\nTROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md
```
In general you can use the [`ldd`](<https://en.wikipedia.org/wiki/Ldd_(Unix)>) utility to figure out what shared libraries
are not installed in your system:
```bash
cd <grafana-image-render plugin directory>
ldd chrome-headless-shell/linux-132.0.6781.0/chrome-headless-shell-linux64/chrome-headless-shell
linux-vdso.so.1 (0x00007fff1bf65000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2047945000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2047924000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f204791a000)
libX11.so.6 => not found
libX11-xcb.so.1 => not found
libxcb.so.1 => not found
libXcomposite.so.1 => not found
...
```
You can find a reference to all the relevant Debian packages for the service to function [in the Dockerfile](https://github.com/grafana/grafana-image-renderer/blob/master/Dockerfile).
If you are using an operating system that is not Debian 12, you should look up what each of those packages are called on your system.
## Certificate signed by internal certificate authorities
In many cases, Grafana runs on internal servers and uses certificates that have not been signed by a CA ([Certificate Authority](https://en.wikipedia.org/wiki/Certificate_authority)) known to Chrome, and therefore cannot be validated. Chrome internally uses NSS ([Network Security Services](https://en.wikipedia.org/wiki/Network_Security_Services)) for cryptographic operations such as the validation of certificates.
If you are using the Grafana Image Renderer with a Grafana server that uses a certificate signed by such a custom CA (for example a company-internal CA), rendering images will fail and you will see messages like this in the Grafana log:
```
t=2019-12-04T12:39:22+0000 lvl=error msg="Render request failed" logger=rendering error=map[] url="https://192.168.106.101:3443/d-solo/zxDJxNaZk/graphite-metrics?orgId=1&refresh=1m&from=1575438321300&to=1575459921300&var-Host=master1&panelId=4&width=1000&height=500&tz=Europe%2FBerlin&render=1" timestamp=0001-01-01T00:00:00.000Z
t=2019-12-04T12:39:22+0000 lvl=error msg="Rendering failed." logger=context userId=1 orgId=1 uname=admin error="Rendering failed: Error: net::ERR_CERT_AUTHORITY_INVALID at https://192.168.106.101:3443/d-solo/zxDJxNaZk/graphite-metrics?orgId=1&refresh=1m&from=1575438321300&to=1575459921300&var-Host=master1&panelId=4&width=1000&height=500&tz=Europe%2FBerlin&render=1"
t=2019-12-04T12:39:22+0000 lvl=error msg="Request Completed" logger=context userId=1 orgId=1 uname=admin method=GET path=/render/d-solo/zxDJxNaZk/graphite-metrics status=500 remote_addr=192.168.106.101 time_ms=310 size=1722 referer="https://grafana.xxx-xxx/d/zxDJxNaZk/graphite-metrics?orgId=1&refresh=1m"
```
If this happens, then you have to add the certificate to the trust store. If you have the certificate file for the internal root CA in the file `internal-root-ca.crt.pem`, then use these commands to create a user specific NSS trust store for the Grafana user (`grafana` for the purpose of this example) and execute the following steps:
**Linux:**
```
[root@server ~]# [ -d /usr/share/grafana/.pki/nssdb ] || mkdir -p /usr/share/grafana/.pki/nssdb
[root@server ~]# certutil -d sql:/usr/share/grafana/.pki/nssdb -A -n internal-root-ca -t C -i /etc/pki/tls/certs/internal-root-ca.crt.pem
[root@server ~]# chown -R grafana: /usr/share/grafana/.pki/nssdb
```
You may also have to use other tooling than `certutil`, such as `update-ca-certificates` and its accompanying paths.
This depends on the Linux distribution you use; distributions often have a wiki with this type of information.
**Windows:**
```
certutil addstore "Root" <path>/internal-root-ca.crt.pem
```
**Container:**
```Dockerfile
FROM grafana/grafana-image-renderer:latest
# Elevate our permissions to access system resources.
USER root
RUN mkdir -p /usr/local/share/ca-certificates/
# Convert from .pem to .crt
RUN openssl x509 -inform PEM -in rootCA.pem -out /usr/local/share/ca-certificates/rootCA.crt
# Regenerate the CA certificates in the container.
RUN update-ca-certificates --fresh
# Reassume the nonroot user for the service execution.
USER nonroot
# Some CA certificates also need to explicitly be included in the user's network security services database.
# certutil is shipped in v4.0.8 and onwards of the image.
RUN mkdir -p /home/nonroot/.pki/nssdb
RUN certutil -d sql:/home/nonroot/.pki/nssdb -A -n internal-root-ca -t C -i /usr/local/share/ca-certificates/rootCA.crt
```
{{< admonition type="note" >}}
The container image was based on Alpine until v4.0.0.
After this point, it is based on distroless Debian.
{{< /admonition >}}
## Custom Chrome/Chromium
As a last resort, if you already have [Chrome](https://www.google.com/chrome/) or [Chromium](https://www.chromium.org/)
installed on your system, then you can configure the Grafana Image renderer plugin to use this
instead of the pre-packaged version of Chromium.
{{< admonition type="note" >}}
Please note that this is not recommended, since you may encounter problems if the installed version of Chrome/Chromium is not
compatible with the [Grafana Image renderer plugin](/grafana/plugins/grafana-image-renderer).
{{< /admonition >}}
To override the path to the Chrome/Chromium executable in plugin mode, set an environment variable and make sure that it's available for the Grafana process. For example:
```bash
export GF_PLUGIN_RENDERING_CHROME_BIN="/usr/bin/chromium-browser"
```
In remote rendering mode, you need to set the environment variable or update the configuration file and make sure that it's available for the image rendering service process:
```bash
CHROME_BIN="/usr/bin/chromium-browser"
```
```json
{
"rendering": {
"chromeBin": "/usr/bin/chromium-browser"
}
}
```

View File

@@ -1,19 +0,0 @@
---
title: Panel mouse time zoom
comments: |
This file is used in the following visualizations: candlestick, heatmap, state timeline, status history, time series.
---
You can zoom the panel time range in and out, which in turn, changes the dashboard time range.
**Zoom in** - Click and drag on the panel to zoom in on a particular time range.
**Zoom out** - Double-click anywhere on the panel to zoom out the time range.
When you zoom out, the range doubles with each double-click, adding equal time to each side of the range.
For example, if the original time range is from 9:00 to 9:59, the time range changes as follow with each double-click:
- Next range: 8:30 - 10:29
- Next range: 7:30 - 11:29
For screen recordings showing these interactions, refer to the [Panel overview documentation](https://grafana.com/docs/grafana/<GRAFANA_VERSION>/visualizations/panels-visualizations/panel-overview/#zoom-panel-time-range).

View File

@@ -175,52 +175,6 @@ By hovering over a panel with the mouse you can use some shortcuts that will tar
- `pl`: Hide or show legend
- `pr`: Remove Panel
## Zoom panel time range
You can zoom the panel time range in and out, which in turn, changes the dashboard time range.
This feature is supported for the following visualizations:
- Candlestick
- Heatmap
- State timeline
- Status history
- Time series
### Zoom in
Click and drag on the panel to zoom in on a particular time range.
The following screen recordings show this interaction in the time series and x visualizations:
Time series
{{< video-embed src="/media/docs/grafana/panels-visualizations/recording-ts-time-zoom-in-mouse.mp4" >}}
Candlestick
{{< video-embed src="/media/docs/grafana/panels-visualizations/recording-candle-panel-time-zoom-in-mouse.mp4" >}}
### Zoom out
Double-click anywhere on the panel to zoom out the time range.
The range doubles with each double-click, adding equal time to each side of the range.
For example, if the original time range is from 9:00 to 9:59, the time range changes as follows with each double-click:
- Next range: 8:30 - 10:29
- Next range: 7:30 - 11:29
The following screen recordings demonstrate the preceding example in the time series and x visualizations:
Time series
{{< video-embed src="/media/docs/grafana/panels-visualizations/recording-ts-time-zoom-out-mouse.mp4" >}}
Heatmap
{{< video-embed src="/media/docs/grafana/panels-visualizations/recording-heatmap-panel-time-zoom-out-mouse.mp4" >}}
## Add a panel
To add a panel in a new dashboard click **+ Add visualization** in the middle of the dashboard:

View File

@@ -1,6 +1,5 @@
---
aliases:
- ../../panels-visualizations/query-transform-data/sql-expressions/ # /docs/grafana/next/panels-visualizations/query-transform-data/sql-expressions/
labels:
products:
- cloud

View File

@@ -92,10 +92,6 @@ The data is converted as follows:
{{< figure src="/media/docs/grafana/panels-visualizations/screenshot-candles-volume-v11.6.png" max-width="750px" alt="A candlestick visualization showing the price movements of specific asset." >}}
## Zoom panel time range
{{< docs/shared lookup="visualizations/panel-zoom.md" source="grafana" version="<GRAFANA_VERSION>" >}}
## Configuration options
{{< docs/shared lookup="visualizations/config-options-intro.md" source="grafana" version="<GRAFANA_VERSION>" >}}

View File

@@ -79,10 +79,6 @@ The data is converted as follows:
{{< figure src="/static/img/docs/heatmap-panel/heatmap.png" max-width="1025px" alt="A heatmap visualization showing the random walk distribution over time" >}}
## Zoom panel time range
{{< docs/shared lookup="visualizations/panel-zoom.md" source="grafana" version="<GRAFANA_VERSION>" >}}
## Configuration options
{{< docs/shared lookup="visualizations/config-options-intro.md" source="grafana" version="<GRAFANA_VERSION>" >}}

View File

@@ -93,10 +93,6 @@ You can also create a state timeline visualization using time series data. To do
![State timeline with time series](/media/docs/grafana/panels-visualizations/screenshot-state-timeline-time-series-v11.4.png)
## Zoom panel time range
{{< docs/shared lookup="visualizations/panel-zoom.md" source="grafana" version="<GRAFANA_VERSION>" >}}
## Configuration options
{{< docs/shared lookup="visualizations/config-options-intro.md" source="grafana" version="<GRAFANA_VERSION>" >}}

View File

@@ -85,10 +85,6 @@ The data is converted as follows:
{{< figure src="/static/img/docs/status-history-panel/status_history.png" max-width="1025px" alt="A status history panel with two time columns showing the status of two servers" >}}
## Zoom panel time range
{{< docs/shared lookup="visualizations/panel-zoom.md" source="grafana" version="<GRAFANA_VERSION>" >}}
## Configuration options
{{< docs/shared lookup="visualizations/config-options-intro.md" source="grafana" version="<GRAFANA_VERSION>" >}}

View File

@@ -167,10 +167,6 @@ The following example shows three series: Min, Max, and Value. The Min and Max s
{{< docs/shared lookup="visualizations/multiple-y-axes.md" source="grafana" version="<GRAFANA_VERSION>" leveloffset="+2" >}}
## Zoom panel time range
{{< docs/shared lookup="visualizations/panel-zoom.md" source="grafana" version="<GRAFANA_VERSION>" >}}
## Configuration options
{{< docs/shared lookup="visualizations/config-options-intro.md" source="grafana" version="<GRAFANA_VERSION>" >}}

View File

@@ -22,6 +22,8 @@ test.describe(
await dashboardPage.getByGrafanaSelector(selectors.components.NavToolbar.editDashboard.editButton).click();
await dashboardPage.getByGrafanaSelector(selectors.components.PanelEditor.Outline.section).click();
// Should be able to click Variables item in outline to see add variable button
await dashboardPage.getByGrafanaSelector(selectors.components.PanelEditor.Outline.item('Variables')).click();
await expect(

View File

@@ -199,6 +199,7 @@ test.describe(
.click();
// Open the modal editor in the side pane
await dashboardPage.getByGrafanaSelector(selectors.components.PanelEditor.Outline.section).click();
await dashboardPage.getByGrafanaSelector(selectors.components.PanelEditor.Outline.node('Variables')).click();
await dashboardPage.getByGrafanaSelector(selectors.components.PanelEditor.Outline.item('foo')).click();
await openModal(dashboardPage, selectors);

Some files were not shown because too many files have changed in this diff Show More