mirror of https://github.com/grafana/grafana
alerting/alert-rule-versions-1_TR
commit
2d7144cf99
@ -0,0 +1,5 @@ |
||||
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT |
||||
|
||||
go 1.23.4 |
||||
|
||||
require github.com/grafana/cog v0.0.15 // cmd/cli |
@ -0,0 +1,8 @@ |
||||
.PHONY: generate |
||||
generate: |
||||
@grafana-app-sdk generate -g ./pkg/apis --grouping=group --postprocess
|
||||
# HACK: Clean up generated CRD files.
|
||||
# TODO: The SDK currently omits generating the manifest Go file with `--defencoding=none`,
|
||||
# which we would normally use here to skip generating the CRD files.
|
||||
# This needs to be addressed.
|
||||
@rm -rf definitions
|
@ -0,0 +1,85 @@ |
||||
module github.com/grafana/grafana/apps/advisor |
||||
|
||||
go 1.23.4 |
||||
|
||||
require ( |
||||
github.com/grafana/grafana-app-sdk v0.30.0 |
||||
k8s.io/apimachinery v0.32.0 |
||||
k8s.io/klog/v2 v2.130.1 |
||||
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f |
||||
) |
||||
|
||||
require ( |
||||
github.com/beorn7/perks v1.0.1 // indirect |
||||
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 // indirect |
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect |
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect |
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect |
||||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect |
||||
github.com/evanphx/json-patch v5.6.0+incompatible // indirect |
||||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect |
||||
github.com/getkin/kin-openapi v0.128.0 // indirect |
||||
github.com/go-logr/logr v1.4.2 // indirect |
||||
github.com/go-logr/stdr v1.2.2 // indirect |
||||
github.com/go-openapi/jsonpointer v0.21.0 // indirect |
||||
github.com/go-openapi/jsonreference v0.21.0 // indirect |
||||
github.com/go-openapi/swag v0.23.0 // indirect |
||||
github.com/gogo/protobuf v1.3.2 // indirect |
||||
github.com/golang/protobuf v1.5.4 // indirect |
||||
github.com/google/gnostic-models v0.6.8 // indirect |
||||
github.com/google/go-cmp v0.6.0 // indirect |
||||
github.com/google/gofuzz v1.2.0 // indirect |
||||
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect |
||||
github.com/google/uuid v1.6.0 // indirect |
||||
github.com/grafana/grafana-app-sdk/logging v0.29.0 // indirect |
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 // indirect |
||||
github.com/hashicorp/errwrap v1.1.0 // indirect |
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect |
||||
github.com/invopop/yaml v0.3.1 // indirect |
||||
github.com/josharian/intern v1.0.0 // indirect |
||||
github.com/json-iterator/go v1.1.12 // indirect |
||||
github.com/klauspost/compress v1.17.11 // indirect |
||||
github.com/mailru/easyjson v0.7.7 // indirect |
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect |
||||
github.com/modern-go/reflect2 v1.0.2 // indirect |
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect |
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect |
||||
github.com/perimeterx/marshmallow v1.1.5 // indirect |
||||
github.com/prometheus/client_golang v1.20.5 // indirect |
||||
github.com/prometheus/client_model v0.6.1 // indirect |
||||
github.com/prometheus/common v0.61.0 // indirect |
||||
github.com/prometheus/procfs v0.15.1 // indirect |
||||
github.com/puzpuzpuz/xsync/v2 v2.5.1 // indirect |
||||
github.com/spf13/pflag v1.0.5 // indirect |
||||
github.com/x448/float16 v0.8.4 // indirect |
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect |
||||
go.opentelemetry.io/otel v1.33.0 // indirect |
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 // indirect |
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0 // indirect |
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.33.0 // indirect |
||||
go.opentelemetry.io/otel/metric v1.33.0 // indirect |
||||
go.opentelemetry.io/otel/sdk v1.33.0 // indirect |
||||
go.opentelemetry.io/otel/trace v1.33.0 // indirect |
||||
go.opentelemetry.io/proto/otlp v1.5.0 // indirect |
||||
golang.org/x/net v0.34.0 // indirect |
||||
golang.org/x/oauth2 v0.25.0 // indirect |
||||
golang.org/x/sync v0.10.0 // indirect |
||||
golang.org/x/sys v0.29.0 // indirect |
||||
golang.org/x/term v0.28.0 // indirect |
||||
golang.org/x/text v0.21.0 // indirect |
||||
golang.org/x/time v0.9.0 // indirect |
||||
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect |
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250102185135-69823020774d // indirect |
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250102185135-69823020774d // indirect |
||||
google.golang.org/grpc v1.69.4 // indirect |
||||
google.golang.org/protobuf v1.36.1 // indirect |
||||
gopkg.in/inf.v0 v0.9.1 // indirect |
||||
gopkg.in/yaml.v3 v3.0.1 // indirect |
||||
k8s.io/api v0.32.0 // indirect |
||||
k8s.io/apiextensions-apiserver v0.32.0 // indirect |
||||
k8s.io/client-go v0.32.0 // indirect |
||||
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect |
||||
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect |
||||
sigs.k8s.io/structured-merge-diff/v4 v4.5.0 // indirect |
||||
sigs.k8s.io/yaml v1.4.0 // indirect |
||||
) |
@ -0,0 +1,226 @@ |
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= |
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= |
||||
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874 h1:N7oVaKyGp8bttX0bfZGmcGkjz7DLQXhAn3DNd3T0ous= |
||||
github.com/bradfitz/gomemcache v0.0.0-20230905024940-24af94b03874/go.mod h1:r5xuitiExdLAJ09PR7vBVENGvp4ZuTBeWTGtxuX3K+c= |
||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= |
||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= |
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= |
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= |
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= |
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
||||
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= |
||||
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= |
||||
github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= |
||||
github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= |
||||
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= |
||||
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= |
||||
github.com/getkin/kin-openapi v0.128.0 h1:jqq3D9vC9pPq1dGcOCv7yOp1DaEe7c/T1vzcLbITSp4= |
||||
github.com/getkin/kin-openapi v0.128.0/go.mod h1:OZrfXzUfGrNbsKj+xmFBx6E5c6yH3At/tAKSc2UszXM= |
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= |
||||
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= |
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= |
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= |
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= |
||||
github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= |
||||
github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= |
||||
github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ= |
||||
github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4= |
||||
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= |
||||
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= |
||||
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= |
||||
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= |
||||
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= |
||||
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= |
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= |
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= |
||||
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= |
||||
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= |
||||
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= |
||||
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= |
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= |
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= |
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= |
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= |
||||
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= |
||||
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= |
||||
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg= |
||||
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= |
||||
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/grafana-app-sdk v0.30.0 h1:Hqn2pETu2mQ4RpWkZYEQfu01P7xd1Z1Gj+HX/8aB0tw= |
||||
github.com/grafana/grafana-app-sdk v0.30.0/go.mod h1:jhfqNIovb+Mes2vdMf9iMCWQkp1GTNtyNuExONtiNuk= |
||||
github.com/grafana/grafana-app-sdk/logging v0.29.0 h1:mgbXaAf33aFwqwGVeaX30l8rkeAJH0iACgX5Rn6YkN4= |
||||
github.com/grafana/grafana-app-sdk/logging v0.29.0/go.mod h1:xy6ZyVXl50Z3DBDLybvBPphbykPhuVNed/VNmen9DQM= |
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 h1:VNqngBF40hVlDloBruUehVYC3ArSgIyScOAyMRqBxRg= |
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1/go.mod h1:RBRO7fro65R6tjKzYgLAFo0t1QEXY1Dp+i/bvpRiqiQ= |
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= |
||||
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= |
||||
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= |
||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= |
||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= |
||||
github.com/invopop/yaml v0.3.1 h1:f0+ZpmhfBSS4MhG+4HYseMdJhoeeopbSKbq5Rpeelso= |
||||
github.com/invopop/yaml v0.3.1/go.mod h1:PMOp3nn4/12yEZUFfmOuNHJsZToEEOwoWsT+D81KkeA= |
||||
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= |
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= |
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= |
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= |
||||
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= |
||||
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= |
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= |
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= |
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= |
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= |
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= |
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= |
||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= |
||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= |
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= |
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= |
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= |
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= |
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= |
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= |
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= |
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= |
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= |
||||
github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM= |
||||
github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= |
||||
github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4= |
||||
github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= |
||||
github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s= |
||||
github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= |
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= |
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= |
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= |
||||
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
||||
github.com/prometheus/client_golang v1.20.5 h1:cxppBPuYhUnsO6yo/aoRol4L7q7UFfdm+bR9r+8l63Y= |
||||
github.com/prometheus/client_golang v1.20.5/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= |
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= |
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= |
||||
github.com/prometheus/common v0.61.0 h1:3gv/GThfX0cV2lpO7gkTUwZru38mxevy90Bj8YFSRQQ= |
||||
github.com/prometheus/common v0.61.0/go.mod h1:zr29OCN/2BsJRaFwG8QOBr41D6kkchKbpeNH7pAjb/s= |
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= |
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= |
||||
github.com/puzpuzpuz/xsync/v2 v2.5.1 h1:mVGYAvzDSu52+zaGyNjC+24Xw2bQi3kTr4QJ6N9pIIU= |
||||
github.com/puzpuzpuz/xsync/v2 v2.5.1/go.mod h1:gD2H2krq/w52MfPLE+Uy64TzJDVY7lP2znR9qmR35kU= |
||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= |
||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= |
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= |
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= |
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= |
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= |
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= |
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= |
||||
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= |
||||
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= |
||||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= |
||||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= |
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= |
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= |
||||
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= |
||||
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= |
||||
go.opentelemetry.io/otel v1.33.0 h1:/FerN9bax5LoK51X/sI0SVYrjSE0/yUL7DpxW4K3FWw= |
||||
go.opentelemetry.io/otel v1.33.0/go.mod h1:SUUkR6csvUQl+yjReHu5uM3EtVV7MBm5FHKRlNx4I8I= |
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 h1:Vh5HayB/0HHfOQA7Ctx69E/Y/DcQSMPpKANYVMQ7fBA= |
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0/go.mod h1:cpgtDBaqD/6ok/UG0jT15/uKjAY8mRA53diogHBg3UI= |
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0 h1:5pojmb1U1AogINhN3SurB+zm/nIcusopeBNp42f45QM= |
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0/go.mod h1:57gTHJSE5S1tqg+EKsLPlTWhpHMsWlVmer+LA926XiA= |
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.33.0 h1:wpMfgF8E1rkrT1Z6meFh1NDtownE9Ii3n3X2GJYjsaU= |
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.33.0/go.mod h1:wAy0T/dUbs468uOlkT31xjvqQgEVXv58BRFWEgn5v/0= |
||||
go.opentelemetry.io/otel/metric v1.33.0 h1:r+JOocAyeRVXD8lZpjdQjzMadVZp2M4WmQ+5WtEnklQ= |
||||
go.opentelemetry.io/otel/metric v1.33.0/go.mod h1:L9+Fyctbp6HFTddIxClbQkjtubW6O9QS3Ann/M82u6M= |
||||
go.opentelemetry.io/otel/sdk v1.33.0 h1:iax7M131HuAm9QkZotNHEfstof92xM+N8sr3uHXc2IM= |
||||
go.opentelemetry.io/otel/sdk v1.33.0/go.mod h1:A1Q5oi7/9XaMlIWzPSxLRWOI8nG3FnzHJNbiENQuihM= |
||||
go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc= |
||||
go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8= |
||||
go.opentelemetry.io/otel/trace v1.33.0 h1:cCJuF7LRjUFso9LPnEAHJDB2pqzp+hbO8eu1qqW2d/s= |
||||
go.opentelemetry.io/otel/trace v1.33.0/go.mod h1:uIcdVUZMpTAmz0tI1z04GoVSezK37CbGV4fr1f2nBck= |
||||
go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU/3i4= |
||||
go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4= |
||||
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= |
||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= |
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= |
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= |
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= |
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= |
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= |
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= |
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= |
||||
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= |
||||
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= |
||||
golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70= |
||||
golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= |
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
||||
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= |
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= |
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
||||
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= |
||||
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= |
||||
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= |
||||
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= |
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= |
||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= |
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= |
||||
golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY= |
||||
golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= |
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= |
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= |
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= |
||||
golang.org/x/tools v0.29.0 h1:Xx0h3TtM9rzQpQuR4dKLrdglAmCEN5Oi+P74JdhdzXE= |
||||
golang.org/x/tools v0.29.0/go.mod h1:KMQVMRsVxU6nHCFXrBPhDB8XncLNLM0lIy/F14RP588= |
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
||||
gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= |
||||
gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= |
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250102185135-69823020774d h1:H8tOf8XM88HvKqLTxe755haY6r1fqqzLbEnfrmLXlSA= |
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250102185135-69823020774d/go.mod h1:2v7Z7gP2ZUOGsaFyxATQSRoBnKygqVq2Cwnvom7QiqY= |
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250102185135-69823020774d h1:xJJRGY7TJcvIlpSrN3K6LAWgNFUILlO+OMAqtg9aqnw= |
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250102185135-69823020774d/go.mod h1:3ENsm/5D1mzDyhpzeRi1NR784I0BcofWBoSc5QqqMK4= |
||||
google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A= |
||||
google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= |
||||
google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= |
||||
google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= |
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= |
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= |
||||
gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= |
||||
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= |
||||
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= |
||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= |
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
||||
k8s.io/api v0.32.0 h1:OL9JpbvAU5ny9ga2fb24X8H6xQlVp+aJMFlgtQjR9CE= |
||||
k8s.io/api v0.32.0/go.mod h1:4LEwHZEf6Q/cG96F3dqR965sYOfmPM7rq81BLgsE0p0= |
||||
k8s.io/apiextensions-apiserver v0.32.0 h1:S0Xlqt51qzzqjKPxfgX1xh4HBZE+p8KKBq+k2SWNOE0= |
||||
k8s.io/apiextensions-apiserver v0.32.0/go.mod h1:86hblMvN5yxMvZrZFX2OhIHAuFIMJIZ19bTvzkP+Fmw= |
||||
k8s.io/apimachinery v0.32.0 h1:cFSE7N3rmEEtv4ei5X6DaJPHHX0C+upp+v5lVPiEwpg= |
||||
k8s.io/apimachinery v0.32.0/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE= |
||||
k8s.io/client-go v0.32.0 h1:DimtMcnN/JIKZcrSrstiwvvZvLjG0aSxy8PxN8IChp8= |
||||
k8s.io/client-go v0.32.0/go.mod h1:boDWvdM1Drk4NJj/VddSLnx59X3OPgwrOo0vGbtq9+8= |
||||
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= |
||||
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= |
||||
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y= |
||||
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4= |
||||
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= |
||||
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= |
||||
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= |
||||
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= |
||||
sigs.k8s.io/structured-merge-diff/v4 v4.5.0 h1:nbCitCK2hfnhyiKo6uf2HxUPTCodY6Qaf85SbDIaMBk= |
||||
sigs.k8s.io/structured-merge-diff/v4 v4.5.0/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= |
||||
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= |
||||
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= |
@ -0,0 +1,42 @@ |
||||
package advisor |
||||
|
||||
check: { |
||||
kind: "Check" |
||||
pluralName: "Checks" |
||||
current: "v0alpha1" |
||||
versions: { |
||||
"v0alpha1": { |
||||
codegen: { |
||||
frontend: false |
||||
backend: true |
||||
} |
||||
validation: { |
||||
operations: [ |
||||
"CREATE", |
||||
"UPDATE", |
||||
] |
||||
} |
||||
schema: { |
||||
spec: { |
||||
// Generic data input that a check can receive |
||||
data?: [string]: string |
||||
} |
||||
status: { |
||||
report: { |
||||
// Number of elements analyzed |
||||
count: int |
||||
// List of errors |
||||
errors: [...{ |
||||
// Severity of the error |
||||
severity: "high" | "low" |
||||
// Human readable reason for the error |
||||
reason: string |
||||
// Action to take to resolve the error |
||||
action: string |
||||
}] |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,4 @@ |
||||
module: "github.com/grafana/grafana/apps/advisor/kinds" |
||||
language: { |
||||
version: "v0.9.0" |
||||
} |
@ -0,0 +1,9 @@ |
||||
package advisor |
||||
|
||||
manifest: { |
||||
appName: "advisor" |
||||
groupOverride: "advisor.grafana.app" |
||||
kinds: [ |
||||
check, |
||||
] |
||||
} |
@ -0,0 +1,28 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"io" |
||||
|
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
) |
||||
|
||||
// CheckJSONCodec is an implementation of resource.Codec for kubernetes JSON encoding
|
||||
type CheckJSONCodec struct{} |
||||
|
||||
// Read reads JSON-encoded bytes from `reader` and unmarshals them into `into`
|
||||
func (*CheckJSONCodec) Read(reader io.Reader, into resource.Object) error { |
||||
return json.NewDecoder(reader).Decode(into) |
||||
} |
||||
|
||||
// Write writes JSON-encoded bytes into `writer` marshaled from `from`
|
||||
func (*CheckJSONCodec) Write(writer io.Writer, from resource.Object) error { |
||||
return json.NewEncoder(writer).Encode(from) |
||||
} |
||||
|
||||
// Interface compliance checks
|
||||
var _ resource.Codec = &CheckJSONCodec{} |
@ -0,0 +1,28 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
time "time" |
||||
) |
||||
|
||||
// metadata contains embedded CommonMetadata and can be extended with custom string fields
|
||||
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
|
||||
// without external reference as using the CommonMetadata reference breaks thema codegen.
|
||||
type CheckMetadata struct { |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
CreatedBy string `json:"createdBy"` |
||||
Uid string `json:"uid"` |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Generation int64 `json:"generation"` |
||||
UpdatedBy string `json:"updatedBy"` |
||||
Labels map[string]string `json:"labels"` |
||||
} |
||||
|
||||
// NewCheckMetadata creates a new CheckMetadata object.
|
||||
func NewCheckMetadata() *CheckMetadata { |
||||
return &CheckMetadata{} |
||||
} |
@ -0,0 +1,266 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"fmt" |
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
||||
"k8s.io/apimachinery/pkg/runtime" |
||||
"k8s.io/apimachinery/pkg/runtime/schema" |
||||
"k8s.io/apimachinery/pkg/types" |
||||
"time" |
||||
) |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type Check struct { |
||||
metav1.TypeMeta `json:",inline" yaml:",inline"` |
||||
metav1.ObjectMeta `json:"metadata" yaml:"metadata"` |
||||
Spec CheckSpec `json:"spec" yaml:"spec"` |
||||
CheckStatus CheckStatus `json:"status" yaml:"status"` |
||||
} |
||||
|
||||
func (o *Check) GetSpec() any { |
||||
return o.Spec |
||||
} |
||||
|
||||
func (o *Check) SetSpec(spec any) error { |
||||
cast, ok := spec.(CheckSpec) |
||||
if !ok { |
||||
return fmt.Errorf("cannot set spec type %#v, not of type Spec", spec) |
||||
} |
||||
o.Spec = cast |
||||
return nil |
||||
} |
||||
|
||||
func (o *Check) GetSubresources() map[string]any { |
||||
return map[string]any{ |
||||
"status": o.CheckStatus, |
||||
} |
||||
} |
||||
|
||||
func (o *Check) GetSubresource(name string) (any, bool) { |
||||
switch name { |
||||
case "status": |
||||
return o.CheckStatus, true |
||||
default: |
||||
return nil, false |
||||
} |
||||
} |
||||
|
||||
func (o *Check) SetSubresource(name string, value any) error { |
||||
switch name { |
||||
case "status": |
||||
cast, ok := value.(CheckStatus) |
||||
if !ok { |
||||
return fmt.Errorf("cannot set status type %#v, not of type CheckStatus", value) |
||||
} |
||||
o.CheckStatus = cast |
||||
return nil |
||||
default: |
||||
return fmt.Errorf("subresource '%s' does not exist", name) |
||||
} |
||||
} |
||||
|
||||
func (o *Check) GetStaticMetadata() resource.StaticMetadata { |
||||
gvk := o.GroupVersionKind() |
||||
return resource.StaticMetadata{ |
||||
Name: o.ObjectMeta.Name, |
||||
Namespace: o.ObjectMeta.Namespace, |
||||
Group: gvk.Group, |
||||
Version: gvk.Version, |
||||
Kind: gvk.Kind, |
||||
} |
||||
} |
||||
|
||||
func (o *Check) SetStaticMetadata(metadata resource.StaticMetadata) { |
||||
o.Name = metadata.Name |
||||
o.Namespace = metadata.Namespace |
||||
o.SetGroupVersionKind(schema.GroupVersionKind{ |
||||
Group: metadata.Group, |
||||
Version: metadata.Version, |
||||
Kind: metadata.Kind, |
||||
}) |
||||
} |
||||
|
||||
func (o *Check) GetCommonMetadata() resource.CommonMetadata { |
||||
dt := o.DeletionTimestamp |
||||
var deletionTimestamp *time.Time |
||||
if dt != nil { |
||||
deletionTimestamp = &dt.Time |
||||
} |
||||
// Legacy ExtraFields support
|
||||
extraFields := make(map[string]any) |
||||
if o.Annotations != nil { |
||||
extraFields["annotations"] = o.Annotations |
||||
} |
||||
if o.ManagedFields != nil { |
||||
extraFields["managedFields"] = o.ManagedFields |
||||
} |
||||
if o.OwnerReferences != nil { |
||||
extraFields["ownerReferences"] = o.OwnerReferences |
||||
} |
||||
return resource.CommonMetadata{ |
||||
UID: string(o.UID), |
||||
ResourceVersion: o.ResourceVersion, |
||||
Generation: o.Generation, |
||||
Labels: o.Labels, |
||||
CreationTimestamp: o.CreationTimestamp.Time, |
||||
DeletionTimestamp: deletionTimestamp, |
||||
Finalizers: o.Finalizers, |
||||
UpdateTimestamp: o.GetUpdateTimestamp(), |
||||
CreatedBy: o.GetCreatedBy(), |
||||
UpdatedBy: o.GetUpdatedBy(), |
||||
ExtraFields: extraFields, |
||||
} |
||||
} |
||||
|
||||
func (o *Check) SetCommonMetadata(metadata resource.CommonMetadata) { |
||||
o.UID = types.UID(metadata.UID) |
||||
o.ResourceVersion = metadata.ResourceVersion |
||||
o.Generation = metadata.Generation |
||||
o.Labels = metadata.Labels |
||||
o.CreationTimestamp = metav1.NewTime(metadata.CreationTimestamp) |
||||
if metadata.DeletionTimestamp != nil { |
||||
dt := metav1.NewTime(*metadata.DeletionTimestamp) |
||||
o.DeletionTimestamp = &dt |
||||
} else { |
||||
o.DeletionTimestamp = nil |
||||
} |
||||
o.Finalizers = metadata.Finalizers |
||||
if o.Annotations == nil { |
||||
o.Annotations = make(map[string]string) |
||||
} |
||||
if !metadata.UpdateTimestamp.IsZero() { |
||||
o.SetUpdateTimestamp(metadata.UpdateTimestamp) |
||||
} |
||||
if metadata.CreatedBy != "" { |
||||
o.SetCreatedBy(metadata.CreatedBy) |
||||
} |
||||
if metadata.UpdatedBy != "" { |
||||
o.SetUpdatedBy(metadata.UpdatedBy) |
||||
} |
||||
// Legacy support for setting Annotations, ManagedFields, and OwnerReferences via ExtraFields
|
||||
if metadata.ExtraFields != nil { |
||||
if annotations, ok := metadata.ExtraFields["annotations"]; ok { |
||||
if cast, ok := annotations.(map[string]string); ok { |
||||
o.Annotations = cast |
||||
} |
||||
} |
||||
if managedFields, ok := metadata.ExtraFields["managedFields"]; ok { |
||||
if cast, ok := managedFields.([]metav1.ManagedFieldsEntry); ok { |
||||
o.ManagedFields = cast |
||||
} |
||||
} |
||||
if ownerReferences, ok := metadata.ExtraFields["ownerReferences"]; ok { |
||||
if cast, ok := ownerReferences.([]metav1.OwnerReference); ok { |
||||
o.OwnerReferences = cast |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
func (o *Check) GetCreatedBy() string { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
return o.ObjectMeta.Annotations["grafana.com/createdBy"] |
||||
} |
||||
|
||||
func (o *Check) SetCreatedBy(createdBy string) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/createdBy"] = createdBy |
||||
} |
||||
|
||||
func (o *Check) GetUpdateTimestamp() time.Time { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
parsed, _ := time.Parse(time.RFC3339, o.ObjectMeta.Annotations["grafana.com/updateTimestamp"]) |
||||
return parsed |
||||
} |
||||
|
||||
func (o *Check) SetUpdateTimestamp(updateTimestamp time.Time) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/updateTimestamp"] = updateTimestamp.Format(time.RFC3339) |
||||
} |
||||
|
||||
func (o *Check) GetUpdatedBy() string { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
return o.ObjectMeta.Annotations["grafana.com/updatedBy"] |
||||
} |
||||
|
||||
func (o *Check) SetUpdatedBy(updatedBy string) { |
||||
if o.ObjectMeta.Annotations == nil { |
||||
o.ObjectMeta.Annotations = make(map[string]string) |
||||
} |
||||
|
||||
o.ObjectMeta.Annotations["grafana.com/updatedBy"] = updatedBy |
||||
} |
||||
|
||||
func (o *Check) Copy() resource.Object { |
||||
return resource.CopyObject(o) |
||||
} |
||||
|
||||
func (o *Check) DeepCopyObject() runtime.Object { |
||||
return o.Copy() |
||||
} |
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.Object = &Check{} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CheckList struct { |
||||
metav1.TypeMeta `json:",inline" yaml:",inline"` |
||||
metav1.ListMeta `json:"metadata" yaml:"metadata"` |
||||
Items []Check `json:"items" yaml:"items"` |
||||
} |
||||
|
||||
func (o *CheckList) DeepCopyObject() runtime.Object { |
||||
return o.Copy() |
||||
} |
||||
|
||||
func (o *CheckList) Copy() resource.ListObject { |
||||
cpy := &CheckList{ |
||||
TypeMeta: o.TypeMeta, |
||||
Items: make([]Check, len(o.Items)), |
||||
} |
||||
o.ListMeta.DeepCopyInto(&cpy.ListMeta) |
||||
for i := 0; i < len(o.Items); i++ { |
||||
if item, ok := o.Items[i].Copy().(*Check); ok { |
||||
cpy.Items[i] = *item |
||||
} |
||||
} |
||||
return cpy |
||||
} |
||||
|
||||
func (o *CheckList) GetItems() []resource.Object { |
||||
items := make([]resource.Object, len(o.Items)) |
||||
for i := 0; i < len(o.Items); i++ { |
||||
items[i] = &o.Items[i] |
||||
} |
||||
return items |
||||
} |
||||
|
||||
func (o *CheckList) SetItems(items []resource.Object) { |
||||
o.Items = make([]Check, len(items)) |
||||
for i := 0; i < len(items); i++ { |
||||
o.Items[i] = *items[i].(*Check) |
||||
} |
||||
} |
||||
|
||||
// Interface compliance compile-time check
|
||||
var _ resource.ListObject = &CheckList{} |
@ -0,0 +1,34 @@ |
||||
//
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
//
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
) |
||||
|
||||
// schema is unexported to prevent accidental overwrites
|
||||
var ( |
||||
schemaCheck = resource.NewSimpleSchema("advisor.grafana.app", "v0alpha1", &Check{}, &CheckList{}, resource.WithKind("Check"), |
||||
resource.WithPlural("checks"), resource.WithScope(resource.NamespacedScope)) |
||||
kindCheck = resource.Kind{ |
||||
Schema: schemaCheck, |
||||
Codecs: map[resource.KindEncoding]resource.Codec{ |
||||
resource.KindEncodingJSON: &CheckJSONCodec{}, |
||||
}, |
||||
} |
||||
) |
||||
|
||||
// Kind returns a resource.Kind for this Schema with a JSON codec
|
||||
func CheckKind() resource.Kind { |
||||
return kindCheck |
||||
} |
||||
|
||||
// Schema returns a resource.SimpleSchema representation of Check
|
||||
func CheckSchema() *resource.SimpleSchema { |
||||
return schemaCheck |
||||
} |
||||
|
||||
// Interface compliance checks
|
||||
var _ resource.Schema = kindCheck |
@ -0,0 +1,14 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CheckSpec struct { |
||||
// Generic data input that a check can receive
|
||||
Data map[string]string `json:"data,omitempty"` |
||||
} |
||||
|
||||
// NewCheckSpec creates a new CheckSpec object.
|
||||
func NewCheckSpec() *CheckSpec { |
||||
return &CheckSpec{} |
||||
} |
@ -0,0 +1,83 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CheckstatusOperatorState struct { |
||||
// lastEvaluation is the ResourceVersion last evaluated
|
||||
LastEvaluation string `json:"lastEvaluation"` |
||||
// state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
State CheckStatusOperatorStateState `json:"state"` |
||||
// descriptiveState is an optional more descriptive state field which has no requirements on format
|
||||
DescriptiveState *string `json:"descriptiveState,omitempty"` |
||||
// details contains any extra information that is operator-specific
|
||||
Details map[string]interface{} `json:"details,omitempty"` |
||||
} |
||||
|
||||
// NewCheckstatusOperatorState creates a new CheckstatusOperatorState object.
|
||||
func NewCheckstatusOperatorState() *CheckstatusOperatorState { |
||||
return &CheckstatusOperatorState{} |
||||
} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CheckStatus struct { |
||||
Report CheckV0alpha1StatusReport `json:"report"` |
||||
// 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]CheckstatusOperatorState `json:"operatorStates,omitempty"` |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"` |
||||
} |
||||
|
||||
// NewCheckStatus creates a new CheckStatus object.
|
||||
func NewCheckStatus() *CheckStatus { |
||||
return &CheckStatus{ |
||||
Report: *NewCheckV0alpha1StatusReport(), |
||||
} |
||||
} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CheckStatusOperatorStateState string |
||||
|
||||
const ( |
||||
CheckStatusOperatorStateStateSuccess CheckStatusOperatorStateState = "success" |
||||
CheckStatusOperatorStateStateInProgress CheckStatusOperatorStateState = "in_progress" |
||||
CheckStatusOperatorStateStateFailed CheckStatusOperatorStateState = "failed" |
||||
) |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CheckStatusSeverity string |
||||
|
||||
const ( |
||||
CheckStatusSeverityHigh CheckStatusSeverity = "high" |
||||
CheckStatusSeverityLow CheckStatusSeverity = "low" |
||||
) |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CheckV0alpha1StatusReportErrors struct { |
||||
// Severity of the error
|
||||
Severity CheckStatusSeverity `json:"severity"` |
||||
// Human readable reason for the error
|
||||
Reason string `json:"reason"` |
||||
// Action to take to resolve the error
|
||||
Action string `json:"action"` |
||||
} |
||||
|
||||
// NewCheckV0alpha1StatusReportErrors creates a new CheckV0alpha1StatusReportErrors object.
|
||||
func NewCheckV0alpha1StatusReportErrors() *CheckV0alpha1StatusReportErrors { |
||||
return &CheckV0alpha1StatusReportErrors{} |
||||
} |
||||
|
||||
// +k8s:openapi-gen=true
|
||||
type CheckV0alpha1StatusReport struct { |
||||
// Number of elements analyzed
|
||||
Count int64 `json:"count"` |
||||
// List of errors
|
||||
Errors []CheckV0alpha1StatusReportErrors `json:"errors"` |
||||
} |
||||
|
||||
// NewCheckV0alpha1StatusReport creates a new CheckV0alpha1StatusReport object.
|
||||
func NewCheckV0alpha1StatusReport() *CheckV0alpha1StatusReport { |
||||
return &CheckV0alpha1StatusReport{} |
||||
} |
@ -0,0 +1,18 @@ |
||||
package v0alpha1 |
||||
|
||||
import "k8s.io/apimachinery/pkg/runtime/schema" |
||||
|
||||
const ( |
||||
// Group is the API group used by all kinds in this package
|
||||
Group = "advisor.grafana.app" |
||||
// Version is the API version used by all kinds in this package
|
||||
Version = "v0alpha1" |
||||
) |
||||
|
||||
var ( |
||||
// GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package
|
||||
GroupVersion = schema.GroupVersion{ |
||||
Group: Group, |
||||
Version: Version, |
||||
} |
||||
) |
@ -0,0 +1,322 @@ |
||||
//go:build !ignore_autogenerated
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
// Code generated by grafana-app-sdk. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
common "k8s.io/kube-openapi/pkg/common" |
||||
spec "k8s.io/kube-openapi/pkg/validation/spec" |
||||
) |
||||
|
||||
func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenAPIDefinition { |
||||
return map[string]common.OpenAPIDefinition{ |
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.Check": schema_pkg_apis_advisor_v0alpha1_Check(ref), |
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckList": schema_pkg_apis_advisor_v0alpha1_CheckList(ref), |
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckSpec": schema_pkg_apis_advisor_v0alpha1_CheckSpec(ref), |
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckStatus": schema_pkg_apis_advisor_v0alpha1_CheckStatus(ref), |
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckV0alpha1StatusReport": schema_pkg_apis_advisor_v0alpha1_CheckV0alpha1StatusReport(ref), |
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckV0alpha1StatusReportErrors": schema_pkg_apis_advisor_v0alpha1_CheckV0alpha1StatusReportErrors(ref), |
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckstatusOperatorState": schema_pkg_apis_advisor_v0alpha1_CheckstatusOperatorState(ref), |
||||
} |
||||
} |
||||
|
||||
func schema_pkg_apis_advisor_v0alpha1_Check(ref common.ReferenceCallback) common.OpenAPIDefinition { |
||||
return common.OpenAPIDefinition{ |
||||
Schema: spec.Schema{ |
||||
SchemaProps: spec.SchemaProps{ |
||||
Type: []string{"object"}, |
||||
Properties: map[string]spec.Schema{ |
||||
"kind": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", |
||||
Type: []string{"string"}, |
||||
Format: "", |
||||
}, |
||||
}, |
||||
"apiVersion": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", |
||||
Type: []string{"string"}, |
||||
Format: "", |
||||
}, |
||||
}, |
||||
"metadata": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Default: map[string]interface{}{}, |
||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), |
||||
}, |
||||
}, |
||||
"spec": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Default: map[string]interface{}{}, |
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckSpec"), |
||||
}, |
||||
}, |
||||
"status": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Default: map[string]interface{}{}, |
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckStatus"), |
||||
}, |
||||
}, |
||||
}, |
||||
Required: []string{"metadata", "spec", "status"}, |
||||
}, |
||||
}, |
||||
Dependencies: []string{ |
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckSpec", "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckStatus", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, |
||||
} |
||||
} |
||||
|
||||
func schema_pkg_apis_advisor_v0alpha1_CheckList(ref common.ReferenceCallback) common.OpenAPIDefinition { |
||||
return common.OpenAPIDefinition{ |
||||
Schema: spec.Schema{ |
||||
SchemaProps: spec.SchemaProps{ |
||||
Type: []string{"object"}, |
||||
Properties: map[string]spec.Schema{ |
||||
"kind": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", |
||||
Type: []string{"string"}, |
||||
Format: "", |
||||
}, |
||||
}, |
||||
"apiVersion": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", |
||||
Type: []string{"string"}, |
||||
Format: "", |
||||
}, |
||||
}, |
||||
"metadata": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Default: map[string]interface{}{}, |
||||
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), |
||||
}, |
||||
}, |
||||
"items": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Type: []string{"array"}, |
||||
Items: &spec.SchemaOrArray{ |
||||
Schema: &spec.Schema{ |
||||
SchemaProps: spec.SchemaProps{ |
||||
Default: map[string]interface{}{}, |
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.Check"), |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
Required: []string{"metadata", "items"}, |
||||
}, |
||||
}, |
||||
Dependencies: []string{ |
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.Check", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, |
||||
} |
||||
} |
||||
|
||||
func schema_pkg_apis_advisor_v0alpha1_CheckSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { |
||||
return common.OpenAPIDefinition{ |
||||
Schema: spec.Schema{ |
||||
SchemaProps: spec.SchemaProps{ |
||||
Type: []string{"object"}, |
||||
Properties: map[string]spec.Schema{ |
||||
"data": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "Generic data input that a check can receive", |
||||
Type: []string{"object"}, |
||||
AdditionalProperties: &spec.SchemaOrBool{ |
||||
Allows: true, |
||||
Schema: &spec.Schema{ |
||||
SchemaProps: spec.SchemaProps{ |
||||
Default: "", |
||||
Type: []string{"string"}, |
||||
Format: "", |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
} |
||||
} |
||||
|
||||
func schema_pkg_apis_advisor_v0alpha1_CheckStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { |
||||
return common.OpenAPIDefinition{ |
||||
Schema: spec.Schema{ |
||||
SchemaProps: spec.SchemaProps{ |
||||
Type: []string{"object"}, |
||||
Properties: map[string]spec.Schema{ |
||||
"report": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Default: map[string]interface{}{}, |
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckV0alpha1StatusReport"), |
||||
}, |
||||
}, |
||||
"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.", |
||||
Type: []string{"object"}, |
||||
AdditionalProperties: &spec.SchemaOrBool{ |
||||
Allows: true, |
||||
Schema: &spec.Schema{ |
||||
SchemaProps: spec.SchemaProps{ |
||||
Default: map[string]interface{}{}, |
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckstatusOperatorState"), |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
"additionalFields": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "additionalFields is reserved for future use", |
||||
Type: []string{"object"}, |
||||
AdditionalProperties: &spec.SchemaOrBool{ |
||||
Allows: true, |
||||
Schema: &spec.Schema{ |
||||
SchemaProps: spec.SchemaProps{ |
||||
Type: []string{"object"}, |
||||
Format: "", |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
Required: []string{"report"}, |
||||
}, |
||||
}, |
||||
Dependencies: []string{ |
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckV0alpha1StatusReport", "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckstatusOperatorState"}, |
||||
} |
||||
} |
||||
|
||||
func schema_pkg_apis_advisor_v0alpha1_CheckV0alpha1StatusReport(ref common.ReferenceCallback) common.OpenAPIDefinition { |
||||
return common.OpenAPIDefinition{ |
||||
Schema: spec.Schema{ |
||||
SchemaProps: spec.SchemaProps{ |
||||
Type: []string{"object"}, |
||||
Properties: map[string]spec.Schema{ |
||||
"count": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "Number of elements analyzed", |
||||
Default: 0, |
||||
Type: []string{"integer"}, |
||||
Format: "int64", |
||||
}, |
||||
}, |
||||
"errors": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "List of errors", |
||||
Type: []string{"array"}, |
||||
Items: &spec.SchemaOrArray{ |
||||
Schema: &spec.Schema{ |
||||
SchemaProps: spec.SchemaProps{ |
||||
Default: map[string]interface{}{}, |
||||
Ref: ref("github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckV0alpha1StatusReportErrors"), |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
Required: []string{"count", "errors"}, |
||||
}, |
||||
}, |
||||
Dependencies: []string{ |
||||
"github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1.CheckV0alpha1StatusReportErrors"}, |
||||
} |
||||
} |
||||
|
||||
func schema_pkg_apis_advisor_v0alpha1_CheckV0alpha1StatusReportErrors(ref common.ReferenceCallback) common.OpenAPIDefinition { |
||||
return common.OpenAPIDefinition{ |
||||
Schema: spec.Schema{ |
||||
SchemaProps: spec.SchemaProps{ |
||||
Type: []string{"object"}, |
||||
Properties: map[string]spec.Schema{ |
||||
"severity": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "Severity of the error", |
||||
Default: "", |
||||
Type: []string{"string"}, |
||||
Format: "", |
||||
}, |
||||
}, |
||||
"reason": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "Human readable reason for the error", |
||||
Default: "", |
||||
Type: []string{"string"}, |
||||
Format: "", |
||||
}, |
||||
}, |
||||
"action": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "Action to take to resolve the error", |
||||
Default: "", |
||||
Type: []string{"string"}, |
||||
Format: "", |
||||
}, |
||||
}, |
||||
}, |
||||
Required: []string{"severity", "reason", "action"}, |
||||
}, |
||||
}, |
||||
} |
||||
} |
||||
|
||||
func schema_pkg_apis_advisor_v0alpha1_CheckstatusOperatorState(ref common.ReferenceCallback) common.OpenAPIDefinition { |
||||
return common.OpenAPIDefinition{ |
||||
Schema: spec.Schema{ |
||||
SchemaProps: spec.SchemaProps{ |
||||
Type: []string{"object"}, |
||||
Properties: map[string]spec.Schema{ |
||||
"lastEvaluation": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "lastEvaluation is the ResourceVersion last evaluated", |
||||
Default: "", |
||||
Type: []string{"string"}, |
||||
Format: "", |
||||
}, |
||||
}, |
||||
"state": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "state describes the state of the lastEvaluation. It is limited to three possible states for machine evaluation.", |
||||
Default: "", |
||||
Type: []string{"string"}, |
||||
Format: "", |
||||
}, |
||||
}, |
||||
"descriptiveState": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "descriptiveState is an optional more descriptive state field which has no requirements on format", |
||||
Type: []string{"string"}, |
||||
Format: "", |
||||
}, |
||||
}, |
||||
"details": { |
||||
SchemaProps: spec.SchemaProps{ |
||||
Description: "details contains any extra information that is operator-specific", |
||||
Type: []string{"object"}, |
||||
AdditionalProperties: &spec.SchemaOrBool{ |
||||
Allows: true, |
||||
Schema: &spec.Schema{ |
||||
SchemaProps: spec.SchemaProps{ |
||||
Type: []string{"object"}, |
||||
Format: "", |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
Required: []string{"lastEvaluation", "state"}, |
||||
}, |
||||
}, |
||||
} |
||||
} |
@ -0,0 +1,58 @@ |
||||
//
|
||||
// This file is generated by grafana-app-sdk
|
||||
// DO NOT EDIT
|
||||
//
|
||||
|
||||
package apis |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
|
||||
"github.com/grafana/grafana-app-sdk/app" |
||||
) |
||||
|
||||
var ( |
||||
rawSchemaCheckv0alpha1 = []byte(`{"spec":{"properties":{"data":{"additionalProperties":{"type":"string"},"description":"Generic data input that a check can receive","type":"object"}},"type":"object"},"status":{"properties":{"additionalFields":{"description":"additionalFields is reserved for future use","type":"object","x-kubernetes-preserve-unknown-fields":true},"operatorStates":{"additionalProperties":{"properties":{"descriptiveState":{"description":"descriptiveState is an optional more descriptive state field which has no requirements on format","type":"string"},"details":{"description":"details contains any extra information that is operator-specific","type":"object","x-kubernetes-preserve-unknown-fields":true},"lastEvaluation":{"description":"lastEvaluation is the ResourceVersion last evaluated","type":"string"},"state":{"description":"state describes the state of the lastEvaluation.\nIt is limited to three possible states for machine evaluation.","enum":["success","in_progress","failed"],"type":"string"}},"required":["lastEvaluation","state"],"type":"object"},"description":"operatorStates is a map of operator ID to operator state evaluations.\nAny operator which consumes this kind SHOULD add its state evaluation information to this field.","type":"object"},"report":{"properties":{"count":{"description":"Number of elements analyzed","type":"integer"},"errors":{"description":"List of errors","items":{"properties":{"action":{"description":"Action to take to resolve the error","type":"string"},"reason":{"description":"Human readable reason for the error","type":"string"},"severity":{"description":"Severity of the error","enum":["high","low"],"type":"string"}},"required":["severity","reason","action"],"type":"object"},"type":"array"}},"required":["count","errors"],"type":"object"}},"required":["report"],"type":"object","x-kubernetes-preserve-unknown-fields":true}}`) |
||||
versionSchemaCheckv0alpha1 app.VersionSchema |
||||
_ = json.Unmarshal(rawSchemaCheckv0alpha1, &versionSchemaCheckv0alpha1) |
||||
) |
||||
|
||||
var appManifestData = app.ManifestData{ |
||||
AppName: "advisor", |
||||
Group: "advisor.grafana.app", |
||||
Kinds: []app.ManifestKind{ |
||||
{ |
||||
Kind: "Check", |
||||
Scope: "Namespaced", |
||||
Conversion: false, |
||||
Versions: []app.ManifestKindVersion{ |
||||
{ |
||||
Name: "v0alpha1", |
||||
Admission: &app.AdmissionCapabilities{ |
||||
Validation: &app.ValidationCapability{ |
||||
Operations: []app.AdmissionOperation{ |
||||
app.AdmissionOperationCreate, |
||||
app.AdmissionOperationUpdate, |
||||
}, |
||||
}, |
||||
}, |
||||
Schema: &versionSchemaCheckv0alpha1, |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
} |
||||
|
||||
func jsonToMap(j string) map[string]any { |
||||
m := make(map[string]any) |
||||
json.Unmarshal([]byte(j), &j) |
||||
return m |
||||
} |
||||
|
||||
func LocalManifest() app.Manifest { |
||||
return app.NewEmbeddedManifest(appManifestData) |
||||
} |
||||
|
||||
func RemoteManifest() app.Manifest { |
||||
return app.NewAPIServerManifest("advisor") |
||||
} |
@ -0,0 +1,100 @@ |
||||
package app |
||||
|
||||
import ( |
||||
"context" |
||||
"fmt" |
||||
|
||||
"github.com/grafana/grafana-app-sdk/app" |
||||
"github.com/grafana/grafana-app-sdk/k8s" |
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
"github.com/grafana/grafana-app-sdk/simple" |
||||
advisorv0alpha1 "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1" |
||||
"github.com/grafana/grafana/apps/advisor/pkg/app/checkregistry" |
||||
"github.com/grafana/grafana/apps/advisor/pkg/app/checks" |
||||
"k8s.io/apimachinery/pkg/runtime/schema" |
||||
"k8s.io/klog/v2" |
||||
) |
||||
|
||||
const ( |
||||
typeLabel = "advisor.grafana.app/type" |
||||
statusAnnotation = "advisor.grafana.app/status" |
||||
) |
||||
|
||||
func New(cfg app.Config) (app.App, error) { |
||||
// Read config
|
||||
checkRegistry, ok := cfg.SpecificConfig.(checkregistry.CheckService) |
||||
if !ok { |
||||
return nil, fmt.Errorf("invalid config type") |
||||
} |
||||
|
||||
// Prepare storage client
|
||||
clientGenerator := k8s.NewClientRegistry(cfg.KubeConfig, k8s.ClientConfig{}) |
||||
client, err := clientGenerator.ClientFor(advisorv0alpha1.CheckKind()) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
// Initialize checks
|
||||
checkMap := map[string]checks.Check{} |
||||
for _, c := range checkRegistry.Checks() { |
||||
checkMap[c.Type()] = c |
||||
} |
||||
|
||||
simpleConfig := simple.AppConfig{ |
||||
Name: "advisor", |
||||
KubeConfig: cfg.KubeConfig, |
||||
InformerConfig: simple.AppInformerConfig{ |
||||
ErrorHandler: func(ctx context.Context, err error) { |
||||
klog.ErrorS(err, "Informer processing error") |
||||
}, |
||||
}, |
||||
ManagedKinds: []simple.AppManagedKind{ |
||||
{ |
||||
Kind: advisorv0alpha1.CheckKind(), |
||||
Validator: &simple.Validator{ |
||||
ValidateFunc: func(ctx context.Context, req *app.AdmissionRequest) error { |
||||
if req.Object != nil { |
||||
_, err := getCheck(req.Object, checkMap) |
||||
return err |
||||
} |
||||
return nil |
||||
}, |
||||
}, |
||||
Watcher: &simple.Watcher{ |
||||
AddFunc: func(ctx context.Context, obj resource.Object) error { |
||||
check, err := getCheck(obj, checkMap) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
return processCheck(ctx, client, obj, check) |
||||
}, |
||||
}, |
||||
}, |
||||
}, |
||||
} |
||||
|
||||
a, err := simple.NewApp(simpleConfig) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
err = a.ValidateManifest(cfg.ManifestData) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
return a, nil |
||||
} |
||||
|
||||
func GetKinds() map[schema.GroupVersion][]resource.Kind { |
||||
gv := schema.GroupVersion{ |
||||
// Group and version are the same for all checks
|
||||
Group: advisorv0alpha1.CheckKind().Group(), |
||||
Version: advisorv0alpha1.CheckKind().Version(), |
||||
} |
||||
return map[schema.GroupVersion][]resource.Kind{ |
||||
gv: { |
||||
advisorv0alpha1.CheckKind(), |
||||
}, |
||||
} |
||||
} |
@ -0,0 +1,31 @@ |
||||
package app |
||||
|
||||
import ( |
||||
"context" |
||||
|
||||
"github.com/grafana/grafana/pkg/apimachinery/identity" |
||||
"k8s.io/apiserver/pkg/authorization/authorizer" |
||||
) |
||||
|
||||
func GetAuthorizer() authorizer.Authorizer { |
||||
return authorizer.AuthorizerFunc(func( |
||||
ctx context.Context, attr authorizer.Attributes, |
||||
) (authorized authorizer.Decision, reason string, err error) { |
||||
if !attr.IsResourceRequest() { |
||||
return authorizer.DecisionNoOpinion, "", nil |
||||
} |
||||
|
||||
// require a user
|
||||
u, err := identity.GetRequester(ctx) |
||||
if err != nil { |
||||
return authorizer.DecisionDeny, "valid user is required", err |
||||
} |
||||
|
||||
// check if is admin
|
||||
if u.GetIsGrafanaAdmin() { |
||||
return authorizer.DecisionAllow, "", nil |
||||
} |
||||
|
||||
return authorizer.DecisionDeny, "forbidden", nil |
||||
}) |
||||
} |
@ -0,0 +1,78 @@ |
||||
package app |
||||
|
||||
import ( |
||||
"context" |
||||
"testing" |
||||
|
||||
"github.com/grafana/grafana/pkg/apimachinery/identity" |
||||
"github.com/stretchr/testify/assert" |
||||
"k8s.io/apiserver/pkg/authorization/authorizer" |
||||
) |
||||
|
||||
func TestGetAuthorizer(t *testing.T) { |
||||
tests := []struct { |
||||
name string |
||||
ctx context.Context |
||||
attr authorizer.Attributes |
||||
expectedDecision authorizer.Decision |
||||
expectedReason string |
||||
expectedErr error |
||||
}{ |
||||
{ |
||||
name: "non-resource request", |
||||
ctx: context.TODO(), |
||||
attr: &mockAttributes{resourceRequest: false}, |
||||
expectedDecision: authorizer.DecisionNoOpinion, |
||||
expectedReason: "", |
||||
expectedErr: nil, |
||||
}, |
||||
{ |
||||
name: "user is admin", |
||||
ctx: identity.WithRequester(context.TODO(), &mockUser{isGrafanaAdmin: true}), |
||||
attr: &mockAttributes{resourceRequest: true}, |
||||
expectedDecision: authorizer.DecisionAllow, |
||||
expectedReason: "", |
||||
expectedErr: nil, |
||||
}, |
||||
{ |
||||
name: "user is not admin", |
||||
ctx: identity.WithRequester(context.TODO(), &mockUser{isGrafanaAdmin: false}), |
||||
attr: &mockAttributes{resourceRequest: true}, |
||||
expectedDecision: authorizer.DecisionDeny, |
||||
expectedReason: "forbidden", |
||||
expectedErr: nil, |
||||
}, |
||||
} |
||||
|
||||
for _, tt := range tests { |
||||
t.Run(tt.name, func(t *testing.T) { |
||||
auth := GetAuthorizer() |
||||
decision, reason, err := auth.Authorize(tt.ctx, tt.attr) |
||||
assert.Equal(t, tt.expectedDecision, decision) |
||||
assert.Equal(t, tt.expectedReason, reason) |
||||
assert.Equal(t, tt.expectedErr, err) |
||||
}) |
||||
} |
||||
} |
||||
|
||||
type mockAttributes struct { |
||||
authorizer.Attributes |
||||
resourceRequest bool |
||||
} |
||||
|
||||
func (m *mockAttributes) IsResourceRequest() bool { |
||||
return m.resourceRequest |
||||
} |
||||
|
||||
// Implement other methods of authorizer.Attributes as needed
|
||||
|
||||
type mockUser struct { |
||||
identity.Requester |
||||
isGrafanaAdmin bool |
||||
} |
||||
|
||||
func (m *mockUser) GetIsGrafanaAdmin() bool { |
||||
return m.isGrafanaAdmin |
||||
} |
||||
|
||||
// Implement other methods of identity.Requester as needed
|
@ -0,0 +1,42 @@ |
||||
package checkregistry |
||||
|
||||
import ( |
||||
"github.com/grafana/grafana/apps/advisor/pkg/app/checks" |
||||
"github.com/grafana/grafana/apps/advisor/pkg/app/checks/datasourcecheck" |
||||
"github.com/grafana/grafana/pkg/plugins" |
||||
"github.com/grafana/grafana/pkg/registry/apis/datasource" |
||||
"github.com/grafana/grafana/pkg/services/datasources" |
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore" |
||||
) |
||||
|
||||
type CheckService interface { |
||||
Checks() []checks.Check |
||||
} |
||||
|
||||
type Service struct { |
||||
datasourceSvc datasources.DataSourceService |
||||
pluginStore pluginstore.Store |
||||
pluginContextProvider datasource.PluginContextWrapper |
||||
pluginClient plugins.Client |
||||
} |
||||
|
||||
func ProvideService(datasourceSvc datasources.DataSourceService, pluginStore pluginstore.Store, |
||||
pluginContextProvider datasource.PluginContextWrapper, pluginClient plugins.Client) *Service { |
||||
return &Service{ |
||||
datasourceSvc: datasourceSvc, |
||||
pluginStore: pluginStore, |
||||
pluginContextProvider: pluginContextProvider, |
||||
pluginClient: pluginClient, |
||||
} |
||||
} |
||||
|
||||
func (s *Service) Checks() []checks.Check { |
||||
return []checks.Check{ |
||||
datasourcecheck.New( |
||||
s.datasourceSvc, |
||||
s.pluginStore, |
||||
s.pluginContextProvider, |
||||
s.pluginClient, |
||||
), |
||||
} |
||||
} |
@ -0,0 +1,96 @@ |
||||
package datasourcecheck |
||||
|
||||
import ( |
||||
"context" |
||||
"fmt" |
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend" |
||||
advisor "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1" |
||||
"github.com/grafana/grafana/apps/advisor/pkg/app/checks" |
||||
"github.com/grafana/grafana/pkg/plugins" |
||||
"github.com/grafana/grafana/pkg/registry/apis/datasource" |
||||
"github.com/grafana/grafana/pkg/services/datasources" |
||||
"github.com/grafana/grafana/pkg/services/pluginsintegration/pluginstore" |
||||
"github.com/grafana/grafana/pkg/util" |
||||
"k8s.io/klog/v2" |
||||
) |
||||
|
||||
func New( |
||||
datasourceSvc datasources.DataSourceService, |
||||
pluginStore pluginstore.Store, |
||||
pluginContextProvider datasource.PluginContextWrapper, |
||||
pluginClient plugins.Client, |
||||
) checks.Check { |
||||
return &check{ |
||||
DatasourceSvc: datasourceSvc, |
||||
PluginStore: pluginStore, |
||||
PluginContextProvider: pluginContextProvider, |
||||
PluginClient: pluginClient, |
||||
} |
||||
} |
||||
|
||||
type check struct { |
||||
DatasourceSvc datasources.DataSourceService |
||||
PluginStore pluginstore.Store |
||||
PluginContextProvider datasource.PluginContextWrapper |
||||
PluginClient plugins.Client |
||||
} |
||||
|
||||
func (c *check) Type() string { |
||||
return "datasource" |
||||
} |
||||
|
||||
func (c *check) Run(ctx context.Context, obj *advisor.CheckSpec) (*advisor.CheckV0alpha1StatusReport, error) { |
||||
// Optionally read the check input encoded in the object
|
||||
// fmt.Println(obj.Data)
|
||||
|
||||
dss, err := c.DatasourceSvc.GetAllDataSources(ctx, &datasources.GetAllDataSourcesQuery{}) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
dsErrs := []advisor.CheckV0alpha1StatusReportErrors{} |
||||
for _, ds := range dss { |
||||
// Data source UID validation
|
||||
err := util.ValidateUID(ds.UID) |
||||
if err != nil { |
||||
dsErrs = append(dsErrs, advisor.CheckV0alpha1StatusReportErrors{ |
||||
Severity: advisor.CheckStatusSeverityLow, |
||||
Reason: fmt.Sprintf("Invalid UID: %s", ds.UID), |
||||
Action: "Change UID", |
||||
}) |
||||
} |
||||
|
||||
// Health check execution
|
||||
pCtx, err := c.PluginContextProvider.PluginContextForDataSource(ctx, &backend.DataSourceInstanceSettings{ |
||||
Type: ds.Type, |
||||
UID: ds.UID, |
||||
APIVersion: ds.APIVersion, |
||||
}) |
||||
if err != nil { |
||||
klog.ErrorS(err, "Error creating plugin context", "datasource", ds.Name) |
||||
continue |
||||
} |
||||
req := &backend.CheckHealthRequest{ |
||||
PluginContext: pCtx, |
||||
Headers: map[string]string{}, |
||||
} |
||||
resp, err := c.PluginClient.CheckHealth(ctx, req) |
||||
if err != nil { |
||||
fmt.Println("Error checking health", err) |
||||
continue |
||||
} |
||||
if resp.Status != backend.HealthStatusOk { |
||||
dsErrs = append(dsErrs, advisor.CheckV0alpha1StatusReportErrors{ |
||||
Severity: advisor.CheckStatusSeverityHigh, |
||||
Reason: fmt.Sprintf("Health check failed: %s", ds.Name), |
||||
Action: "Check datasource", |
||||
}) |
||||
} |
||||
} |
||||
|
||||
return &advisor.CheckV0alpha1StatusReport{ |
||||
Count: int64(len(dss)), |
||||
Errors: dsErrs, |
||||
}, nil |
||||
} |
@ -0,0 +1,114 @@ |
||||
package datasourcecheck |
||||
|
||||
import ( |
||||
"context" |
||||
"testing" |
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend" |
||||
advisor "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1" |
||||
"github.com/grafana/grafana/pkg/plugins" |
||||
"github.com/grafana/grafana/pkg/registry/apis/datasource" |
||||
"github.com/grafana/grafana/pkg/services/datasources" |
||||
"github.com/stretchr/testify/assert" |
||||
) |
||||
|
||||
func TestCheck_Run(t *testing.T) { |
||||
t.Run("should return no errors when all datasources are healthy", func(t *testing.T) { |
||||
datasources := []*datasources.DataSource{ |
||||
{UID: "valid-uid-1", Type: "prometheus", Name: "Prometheus"}, |
||||
{UID: "valid-uid-2", Type: "mysql", Name: "MySQL"}, |
||||
} |
||||
|
||||
mockDatasourceSvc := &MockDatasourceSvc{dss: datasources} |
||||
mockPluginContextProvider := &MockPluginContextProvider{pCtx: backend.PluginContext{}} |
||||
mockPluginClient := &MockPluginClient{res: &backend.CheckHealthResult{Status: backend.HealthStatusOk}} |
||||
|
||||
check := &check{ |
||||
DatasourceSvc: mockDatasourceSvc, |
||||
PluginContextProvider: mockPluginContextProvider, |
||||
PluginClient: mockPluginClient, |
||||
} |
||||
|
||||
report, err := check.Run(context.Background(), &advisor.CheckSpec{}) |
||||
|
||||
assert.NoError(t, err) |
||||
assert.Equal(t, int64(2), report.Count) |
||||
assert.Empty(t, report.Errors) |
||||
}) |
||||
|
||||
t.Run("should return errors when datasource UID is invalid", func(t *testing.T) { |
||||
datasources := []*datasources.DataSource{ |
||||
{UID: "invalid uid", Type: "prometheus", Name: "Prometheus"}, |
||||
} |
||||
|
||||
mockDatasourceSvc := &MockDatasourceSvc{dss: datasources} |
||||
mockPluginContextProvider := &MockPluginContextProvider{pCtx: backend.PluginContext{}} |
||||
mockPluginClient := &MockPluginClient{res: &backend.CheckHealthResult{Status: backend.HealthStatusOk}} |
||||
|
||||
check := &check{ |
||||
DatasourceSvc: mockDatasourceSvc, |
||||
PluginContextProvider: mockPluginContextProvider, |
||||
PluginClient: mockPluginClient, |
||||
} |
||||
|
||||
report, err := check.Run(context.Background(), &advisor.CheckSpec{}) |
||||
|
||||
assert.NoError(t, err) |
||||
assert.Equal(t, int64(1), report.Count) |
||||
assert.Len(t, report.Errors, 1) |
||||
assert.Equal(t, "Invalid UID: invalid uid", report.Errors[0].Reason) |
||||
}) |
||||
|
||||
t.Run("should return errors when datasource health check fails", func(t *testing.T) { |
||||
datasources := []*datasources.DataSource{ |
||||
{UID: "valid-uid-1", Type: "prometheus", Name: "Prometheus"}, |
||||
} |
||||
|
||||
mockDatasourceSvc := &MockDatasourceSvc{dss: datasources} |
||||
mockPluginContextProvider := &MockPluginContextProvider{pCtx: backend.PluginContext{}} |
||||
mockPluginClient := &MockPluginClient{res: &backend.CheckHealthResult{Status: backend.HealthStatusError}} |
||||
|
||||
check := &check{ |
||||
DatasourceSvc: mockDatasourceSvc, |
||||
PluginContextProvider: mockPluginContextProvider, |
||||
PluginClient: mockPluginClient, |
||||
} |
||||
|
||||
report, err := check.Run(context.Background(), &advisor.CheckSpec{}) |
||||
|
||||
assert.NoError(t, err) |
||||
assert.Equal(t, int64(1), report.Count) |
||||
assert.Len(t, report.Errors, 1) |
||||
assert.Equal(t, "Health check failed: Prometheus", report.Errors[0].Reason) |
||||
}) |
||||
} |
||||
|
||||
type MockDatasourceSvc struct { |
||||
datasources.DataSourceService |
||||
|
||||
dss []*datasources.DataSource |
||||
} |
||||
|
||||
func (m *MockDatasourceSvc) GetAllDataSources(ctx context.Context, query *datasources.GetAllDataSourcesQuery) ([]*datasources.DataSource, error) { |
||||
return m.dss, nil |
||||
} |
||||
|
||||
type MockPluginContextProvider struct { |
||||
datasource.PluginContextWrapper |
||||
|
||||
pCtx backend.PluginContext |
||||
} |
||||
|
||||
func (m *MockPluginContextProvider) PluginContextForDataSource(ctx context.Context, datasourceSettings *backend.DataSourceInstanceSettings) (backend.PluginContext, error) { |
||||
return m.pCtx, nil |
||||
} |
||||
|
||||
type MockPluginClient struct { |
||||
plugins.Client |
||||
|
||||
res *backend.CheckHealthResult |
||||
} |
||||
|
||||
func (m *MockPluginClient) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) { |
||||
return m.res, nil |
||||
} |
@ -0,0 +1,13 @@ |
||||
package checks |
||||
|
||||
import ( |
||||
"context" |
||||
|
||||
advisorv0alpha1 "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1" |
||||
) |
||||
|
||||
// Check defines the methods that a check must implement to be executed.
|
||||
type Check interface { |
||||
Run(ctx context.Context, obj *advisorv0alpha1.CheckSpec) (*advisorv0alpha1.CheckV0alpha1StatusReport, error) |
||||
Type() string |
||||
} |
@ -0,0 +1,95 @@ |
||||
package app |
||||
|
||||
import ( |
||||
"context" |
||||
"errors" |
||||
"fmt" |
||||
|
||||
claims "github.com/grafana/authlib/types" |
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
advisorv0alpha1 "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1" |
||||
"github.com/grafana/grafana/apps/advisor/pkg/app/checks" |
||||
"github.com/grafana/grafana/pkg/apimachinery/identity" |
||||
"github.com/grafana/grafana/pkg/apimachinery/utils" |
||||
"github.com/grafana/grafana/pkg/services/user" |
||||
) |
||||
|
||||
func getCheck(obj resource.Object, checks map[string]checks.Check) (checks.Check, error) { |
||||
labels := obj.GetLabels() |
||||
objTypeLabel, ok := labels[typeLabel] |
||||
if !ok { |
||||
return nil, errors.New("missing check type as label") |
||||
} |
||||
c, ok := checks[objTypeLabel] |
||||
if !ok { |
||||
supportedTypes := "" |
||||
for k := range checks { |
||||
supportedTypes += k + ", " |
||||
} |
||||
return nil, fmt.Errorf("unknown check type %s. Supported types are: %s", objTypeLabel, supportedTypes) |
||||
} |
||||
|
||||
return c, nil |
||||
} |
||||
|
||||
func getStatusAnnotation(obj resource.Object) string { |
||||
return obj.GetAnnotations()[statusAnnotation] |
||||
} |
||||
|
||||
func setStatusAnnotation(ctx context.Context, client resource.Client, obj resource.Object, status string) error { |
||||
annotations := obj.GetAnnotations() |
||||
annotations[statusAnnotation] = status |
||||
return client.PatchInto(ctx, obj.GetStaticMetadata().Identifier(), resource.PatchRequest{ |
||||
Operations: []resource.PatchOperation{{ |
||||
Operation: resource.PatchOpAdd, |
||||
Path: "/metadata/annotations", |
||||
Value: annotations, |
||||
}}, |
||||
}, resource.PatchOptions{}, obj) |
||||
} |
||||
|
||||
func processCheck(ctx context.Context, client resource.Client, obj resource.Object, check checks.Check) error { |
||||
status := getStatusAnnotation(obj) |
||||
if status != "" { |
||||
// Check already processed
|
||||
return nil |
||||
} |
||||
c, ok := obj.(*advisorv0alpha1.Check) |
||||
if !ok { |
||||
return fmt.Errorf("invalid object type") |
||||
} |
||||
// Populate ctx with the user that created the check
|
||||
meta, err := utils.MetaAccessor(obj) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
createdBy := meta.GetCreatedBy() |
||||
typ, uid, err := claims.ParseTypeID(createdBy) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
ctx = identity.WithRequester(ctx, &user.SignedInUser{ |
||||
UserUID: uid, |
||||
FallbackType: typ, |
||||
}) |
||||
// Run the checks
|
||||
report, err := check.Run(ctx, &c.Spec) |
||||
if err != nil { |
||||
setErr := setStatusAnnotation(ctx, client, obj, "error") |
||||
if setErr != nil { |
||||
return setErr |
||||
} |
||||
return err |
||||
} |
||||
err = setStatusAnnotation(ctx, client, obj, "processed") |
||||
if err != nil { |
||||
return err |
||||
} |
||||
return client.PatchInto(ctx, obj.GetStaticMetadata().Identifier(), resource.PatchRequest{ |
||||
Operations: []resource.PatchOperation{{ |
||||
Operation: resource.PatchOpAdd, |
||||
Path: "/status/report", |
||||
Value: *report, |
||||
}}, |
||||
}, resource.PatchOptions{}, obj) |
||||
} |
@ -0,0 +1,124 @@ |
||||
package app |
||||
|
||||
import ( |
||||
"context" |
||||
"errors" |
||||
"testing" |
||||
|
||||
"github.com/grafana/grafana-app-sdk/resource" |
||||
advisorv0alpha1 "github.com/grafana/grafana/apps/advisor/pkg/apis/advisor/v0alpha1" |
||||
"github.com/grafana/grafana/apps/advisor/pkg/app/checks" |
||||
"github.com/grafana/grafana/pkg/apimachinery/utils" |
||||
"github.com/stretchr/testify/assert" |
||||
) |
||||
|
||||
func TestGetCheck(t *testing.T) { |
||||
obj := &advisorv0alpha1.Check{} |
||||
obj.SetLabels(map[string]string{typeLabel: "testType"}) |
||||
|
||||
checkMap := map[string]checks.Check{ |
||||
"testType": &mockCheck{}, |
||||
} |
||||
|
||||
check, err := getCheck(obj, checkMap) |
||||
assert.NoError(t, err) |
||||
assert.NotNil(t, check) |
||||
} |
||||
|
||||
func TestGetCheck_MissingLabel(t *testing.T) { |
||||
obj := &advisorv0alpha1.Check{} |
||||
checkMap := map[string]checks.Check{} |
||||
|
||||
_, err := getCheck(obj, checkMap) |
||||
assert.Error(t, err) |
||||
assert.Equal(t, "missing check type as label", err.Error()) |
||||
} |
||||
|
||||
func TestGetCheck_UnknownType(t *testing.T) { |
||||
obj := &advisorv0alpha1.Check{} |
||||
obj.SetLabels(map[string]string{typeLabel: "unknownType"}) |
||||
|
||||
checkMap := map[string]checks.Check{ |
||||
"testType": &mockCheck{}, |
||||
} |
||||
|
||||
_, err := getCheck(obj, checkMap) |
||||
assert.Error(t, err) |
||||
assert.Contains(t, err.Error(), "unknown check type unknownType") |
||||
} |
||||
|
||||
func TestSetStatusAnnotation(t *testing.T) { |
||||
obj := &advisorv0alpha1.Check{} |
||||
obj.SetAnnotations(map[string]string{}) |
||||
client := &mockClient{} |
||||
ctx := context.TODO() |
||||
|
||||
err := setStatusAnnotation(ctx, client, obj, "processed") |
||||
assert.NoError(t, err) |
||||
assert.Equal(t, "processed", obj.GetAnnotations()[statusAnnotation]) |
||||
} |
||||
|
||||
func TestProcessCheck(t *testing.T) { |
||||
obj := &advisorv0alpha1.Check{} |
||||
obj.SetAnnotations(map[string]string{}) |
||||
meta, err := utils.MetaAccessor(obj) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
meta.SetCreatedBy("user:1") |
||||
client := &mockClient{} |
||||
ctx := context.TODO() |
||||
check := &mockCheck{} |
||||
|
||||
err = processCheck(ctx, client, obj, check) |
||||
assert.NoError(t, err) |
||||
assert.Equal(t, "processed", obj.GetAnnotations()[statusAnnotation]) |
||||
} |
||||
|
||||
func TestProcessCheck_AlreadyProcessed(t *testing.T) { |
||||
obj := &advisorv0alpha1.Check{} |
||||
obj.SetAnnotations(map[string]string{statusAnnotation: "processed"}) |
||||
client := &mockClient{} |
||||
ctx := context.TODO() |
||||
check := &mockCheck{} |
||||
|
||||
err := processCheck(ctx, client, obj, check) |
||||
assert.NoError(t, err) |
||||
} |
||||
|
||||
func TestProcessCheck_RunError(t *testing.T) { |
||||
obj := &advisorv0alpha1.Check{} |
||||
obj.SetAnnotations(map[string]string{}) |
||||
meta, err := utils.MetaAccessor(obj) |
||||
if err != nil { |
||||
t.Fatal(err) |
||||
} |
||||
meta.SetCreatedBy("user:1") |
||||
client := &mockClient{} |
||||
ctx := context.TODO() |
||||
|
||||
check := &mockCheck{ |
||||
err: errors.New("run error"), |
||||
} |
||||
|
||||
err = processCheck(ctx, client, obj, check) |
||||
assert.Error(t, err) |
||||
assert.Equal(t, "error", obj.GetAnnotations()[statusAnnotation]) |
||||
} |
||||
|
||||
type mockClient struct { |
||||
resource.Client |
||||
} |
||||
|
||||
func (m *mockClient) PatchInto(ctx context.Context, id resource.Identifier, req resource.PatchRequest, opts resource.PatchOptions, obj resource.Object) error { |
||||
return nil |
||||
} |
||||
|
||||
type mockCheck struct { |
||||
checks.Check |
||||
err error |
||||
} |
||||
|
||||
func (m *mockCheck) Run(ctx context.Context, spec *advisorv0alpha1.CheckSpec) (*advisorv0alpha1.CheckV0alpha1StatusReport, error) { |
||||
return &advisorv0alpha1.CheckV0alpha1StatusReport{}, m.err |
||||
} |
@ -1,3 +1,8 @@ |
||||
.PHONY: generate |
||||
generate: |
||||
@grafana-app-sdk generate -g ./pkg/apis --kindgrouping=group --postprocess --crdencoding none
|
||||
@grafana-app-sdk generate -g ./pkg/apis --grouping=group --postprocess
|
||||
# HACK: Clean up generated CRD files.
|
||||
# TODO: The SDK currently omits generating the manifest Go file with `--defencoding=none`,
|
||||
# which we would normally use here to skip generating the CRD files.
|
||||
# This needs to be addressed.
|
||||
@rm -rf definitions
|
||||
|
@ -1 +1,4 @@ |
||||
module: "github.com/grafana/grafana/apps/playlist/kinds" |
||||
language: { |
||||
version: "v0.9.0" |
||||
} |
||||
|
@ -0,0 +1,9 @@ |
||||
package playlist |
||||
|
||||
manifest: { |
||||
appName: "playlist" |
||||
groupOverride: "playlist.grafana.app" |
||||
kinds: [ |
||||
playlist, |
||||
] |
||||
} |
@ -0,0 +1,18 @@ |
||||
package v0alpha1 |
||||
|
||||
import "k8s.io/apimachinery/pkg/runtime/schema" |
||||
|
||||
const ( |
||||
// Group is the API group used by all kinds in this package
|
||||
Group = "playlist.grafana.app" |
||||
// Version is the API version used by all kinds in this package
|
||||
Version = "v0alpha1" |
||||
) |
||||
|
||||
var ( |
||||
// GroupVersion is a schema.GroupVersion consisting of the Group and Version constants for this package
|
||||
GroupVersion = schema.GroupVersion{ |
||||
Group: Group, |
||||
Version: Version, |
||||
} |
||||
) |
@ -1,32 +1,28 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
package v0alpha1 |
||||
|
||||
import ( |
||||
"time" |
||||
time "time" |
||||
) |
||||
|
||||
// PlaylistMetadata defines model for PlaylistMetadata.
|
||||
// metadata contains embedded CommonMetadata and can be extended with custom string fields
|
||||
// TODO: use CommonMetadata instead of redefining here; currently needs to be defined here
|
||||
// without external reference as using the CommonMetadata reference breaks thema codegen.
|
||||
type PlaylistMetadata struct { |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
CreatedBy string `json:"createdBy"` |
||||
Uid string `json:"uid"` |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Generation int64 `json:"generation"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
UpdateTimestamp time.Time `json:"updateTimestamp"` |
||||
Generation int64 `json:"generation"` |
||||
UpdatedBy string `json:"updatedBy"` |
||||
Labels map[string]string `json:"labels"` |
||||
} |
||||
|
||||
// _kubeObjectMetadata is metadata found in a kubernetes object's metadata field.
|
||||
// It is not exhaustive and only includes fields which may be relevant to a kind's implementation,
|
||||
// As it is also intended to be generic enough to function with any API Server.
|
||||
type PlaylistKubeObjectMetadata struct { |
||||
CreationTimestamp time.Time `json:"creationTimestamp"` |
||||
DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` |
||||
Finalizers []string `json:"finalizers"` |
||||
Generation int64 `json:"generation"` |
||||
Labels map[string]string `json:"labels"` |
||||
ResourceVersion string `json:"resourceVersion"` |
||||
Uid string `json:"uid"` |
||||
// NewPlaylistMetadata creates a new PlaylistMetadata object.
|
||||
func NewPlaylistMetadata() *PlaylistMetadata { |
||||
return &PlaylistMetadata{} |
||||
} |
||||
|
@ -1,70 +1,44 @@ |
||||
package v0alpha1 |
||||
|
||||
// Defines values for PlaylistOperatorStateState.
|
||||
const ( |
||||
PlaylistOperatorStateStateFailed PlaylistOperatorStateState = "failed" |
||||
PlaylistOperatorStateStateInProgress PlaylistOperatorStateState = "in_progress" |
||||
PlaylistOperatorStateStateSuccess PlaylistOperatorStateState = "success" |
||||
) |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
|
||||
// Defines values for PlayliststatusOperatorStateState.
|
||||
const ( |
||||
PlayliststatusOperatorStateStateFailed PlayliststatusOperatorStateState = "failed" |
||||
PlayliststatusOperatorStateStateInProgress PlayliststatusOperatorStateState = "in_progress" |
||||
PlayliststatusOperatorStateStateSuccess PlayliststatusOperatorStateState = "success" |
||||
) |
||||
package v0alpha1 |
||||
|
||||
// PlaylistOperatorState defines model for PlaylistOperatorState.
|
||||
// +k8s:openapi-gen=true
|
||||
type PlaylistOperatorState struct { |
||||
// descriptiveState is an optional more descriptive state field which has no requirements on format
|
||||
DescriptiveState *string `json:"descriptiveState,omitempty"` |
||||
|
||||
// details contains any extra information that is operator-specific
|
||||
Details map[string]interface{} `json:"details,omitempty"` |
||||
|
||||
type PlayliststatusOperatorState struct { |
||||
// lastEvaluation is the ResourceVersion last evaluated
|
||||
LastEvaluation string `json:"lastEvaluation"` |
||||
|
||||
// state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
State PlaylistOperatorStateState `json:"state"` |
||||
State PlaylistStatusOperatorStateState `json:"state"` |
||||
// descriptiveState is an optional more descriptive state field which has no requirements on format
|
||||
DescriptiveState *string `json:"descriptiveState,omitempty"` |
||||
// details contains any extra information that is operator-specific
|
||||
Details map[string]interface{} `json:"details,omitempty"` |
||||
} |
||||
|
||||
// PlaylistOperatorStateState state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
// +k8s:openapi-gen=true
|
||||
type PlaylistOperatorStateState string |
||||
// NewPlayliststatusOperatorState creates a new PlayliststatusOperatorState object.
|
||||
func NewPlayliststatusOperatorState() *PlayliststatusOperatorState { |
||||
return &PlayliststatusOperatorState{} |
||||
} |
||||
|
||||
// PlaylistStatus defines model for PlaylistStatus.
|
||||
// +k8s:openapi-gen=true
|
||||
type PlaylistStatus struct { |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"` |
||||
|
||||
// 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]PlayliststatusOperatorState `json:"operatorStates,omitempty"` |
||||
// additionalFields is reserved for future use
|
||||
AdditionalFields map[string]interface{} `json:"additionalFields,omitempty"` |
||||
} |
||||
|
||||
// PlayliststatusOperatorState defines model for Playliststatus.#OperatorState.
|
||||
// +k8s:openapi-gen=true
|
||||
type PlayliststatusOperatorState struct { |
||||
// descriptiveState is an optional more descriptive state field which has no requirements on format
|
||||
DescriptiveState *string `json:"descriptiveState,omitempty"` |
||||
|
||||
// details contains any extra information that is operator-specific
|
||||
Details map[string]interface{} `json:"details,omitempty"` |
||||
|
||||
// lastEvaluation is the ResourceVersion last evaluated
|
||||
LastEvaluation string `json:"lastEvaluation"` |
||||
|
||||
// state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
State PlayliststatusOperatorStateState `json:"state"` |
||||
// NewPlaylistStatus creates a new PlaylistStatus object.
|
||||
func NewPlaylistStatus() *PlaylistStatus { |
||||
return &PlaylistStatus{} |
||||
} |
||||
|
||||
// PlayliststatusOperatorStateState state describes the state of the lastEvaluation.
|
||||
// It is limited to three possible states for machine evaluation.
|
||||
// +k8s:openapi-gen=true
|
||||
type PlayliststatusOperatorStateState string |
||||
type PlaylistStatusOperatorStateState string |
||||
|
||||
const ( |
||||
PlaylistStatusOperatorStateStateSuccess PlaylistStatusOperatorStateState = "success" |
||||
PlaylistStatusOperatorStateStateInProgress PlaylistStatusOperatorStateState = "in_progress" |
||||
PlaylistStatusOperatorStateStateFailed PlaylistStatusOperatorStateState = "failed" |
||||
) |
||||
|
@ -0,0 +1,351 @@ |
||||
--- |
||||
aliases: |
||||
- ../administration/reports/ # /docs/grafana/latest/administration/reports/ |
||||
- ../enterprise/export-pdf/ # /docs/grafana/latest/enterprise/export-pdf/ |
||||
- ../enterprise/reporting/ # /docs/grafana/latest/enterprise/reporting/ |
||||
- ../panels/create-reports/ # /docs/grafana/latest/panels/create-reports/ |
||||
- reporting/ # /docs/grafana/latest/dashboards/reporting/ |
||||
keywords: |
||||
- grafana |
||||
- reporting |
||||
- export |
||||
- pdf |
||||
labels: |
||||
products: |
||||
- cloud |
||||
- enterprise |
||||
menuTitle: Reporting |
||||
title: Create and manage reports |
||||
description: Generate and share PDF reports from your Grafana dashboards |
||||
weight: 600 |
||||
refs: |
||||
repeat-panels-or-rows: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/panels-visualizations/configure-panel-options/#configure-repeating-panels |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana-cloud/visualizations/panels-visualizations/configure-panel-options/#configure-repeating-panels |
||||
http-apis: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/developers/http_api/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/developers/http_api/ |
||||
image-rendering: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/image-rendering/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/image-rendering/ |
||||
rbac: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/administration/roles-and-permissions/access-control/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/administration/roles-and-permissions/access-control/ |
||||
permission: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/administration/roles-and-permissions/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/administration/roles-and-permissions/ |
||||
role-based-access-control: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/administration/roles-and-permissions/access-control/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/administration/roles-and-permissions/access-control/ |
||||
configuration: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/ |
||||
image-rendering: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/image-rendering/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/image-rendering/ |
||||
templates-and-variables: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/dashboards/variables/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana-cloud/visualizations/dashboards/variables/ |
||||
grafana-enterprise: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/ |
||||
configuration: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#filters |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#filters |
||||
time-range-controls: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/dashboards/use-dashboards/#set-dashboard-time-range |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana-cloud/visualizations/dashboards/use-dashboards/#set-dashboard-time-range |
||||
send-report: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/developers/http_api/reporting/#send-a-report |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana-cloud/developer-resources/api-reference/http-api/reporting/#send-a-report |
||||
smtp: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#smtp |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#smtp |
||||
temp-data-lifetime: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#temp_data_lifetime |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#temp_data_lifetime |
||||
rendering-configuration: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/dashboards/create-reports/report-settings/#rendering-configuration |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/dashboards/create-reports/report-settings/#rendering-configuration |
||||
reporting-configuration: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/enterprise-configuration/#reporting |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/enterprise-configuration/#reporting |
||||
|
||||
--- |
||||
|
||||
# Create and manage reports |
||||
|
||||
**Reporting** allows you to automatically generate PDFs from any of your dashboards and have Grafana email them to interested parties on a schedule. This is available in Grafana Cloud and in Grafana Enterprise. |
||||
|
||||
{{< admonition type="note" >}} |
||||
If you have [Role-based access control](ref:role-based-access-control) enabled, for some actions you would need to have relevant permissions. |
||||
Refer to specific guides to understand what permissions are required. |
||||
{{< /admonition >}} |
||||
|
||||
Any changes you make to a dashboard used in a report are reflected the next time the report is sent. For example, if you change the time range in the dashboard, then the time range in the report also changes, unless you've configured a custom time range. |
||||
|
||||
## Requirements |
||||
|
||||
- SMTP must be configured for reports to be sent. Refer to [SMTP](ref:smtp) in [Configuration](ref:configuration) for more information. |
||||
- The Image Renderer plugin must be installed or the remote rendering service must be set up. Refer to [Image rendering](ref:image-rendering) for more information. |
||||
|
||||
### Rendering configuration |
||||
|
||||
When generating reports, each panel renders separately before being collected in a PDF. You can configure the per-panel rendering timeout and number of concurrently rendered panels. |
||||
|
||||
To make a panel more legible, you can set a scale factor for the rendered images. However, a higher scale factor increases the file size of the generated PDF. |
||||
|
||||
You can also specify custom fonts that support different Unicode scripts. The DejaVu font is the default used for PDF rendering. |
||||
|
||||
These options are available in the [reporting configuration](ref:reporting-configuration) of the `ini` file for Enterprise Grafana. |
||||
|
||||
## Access control |
||||
|
||||
When [RBAC](ref:rbac) is enabled, you need to have the relevant [Permissions](ref:permission) to create and manage reports. |
||||
|
||||
## Create a report |
||||
|
||||
Only organization administrators can create reports by default. You can customize who can create reports with [Role-based access control](ref:role-based-access-control). |
||||
|
||||
The report creation process is multi-step, but you don't need to complete these steps in order and you can skip steps by clicking a step name at the top of the page: |
||||
|
||||
 |
||||
|
||||
To create a report, follow these steps: |
||||
|
||||
1. Click **Dashboards > Reporting** in the main menu. |
||||
1. Click **+ Create a new report**. |
||||
1. Complete the report steps, as needed; you don't need to complete these steps in order and you can skip steps by clicking a step name at the top of the page: |
||||
- [Select dashboard](#1-select-dashboard) |
||||
- [Format report](#2-format-report) |
||||
- [Schedule](#3-schedule) |
||||
- [Share](#4-share) |
||||
- [Confirm](#5-confirm) |
||||
1. Click one of the following buttons in the top-right corner of the screen: |
||||
- **Send now** or **Schedule send** - The report is sent according the schedule you've set. |
||||
- **Save as draft** - You can save a draft at any point during the report creation or update process, even if it's missing required fields. The report won't be sent according to its schedule while it's a draft. |
||||
- **Discard** - Delete the report draft. This action can't be reversed. |
||||
|
||||
### 1. Select dashboard |
||||
|
||||
At this step, select the dashboard or dashboards on which the report is based, as well as the variables and time range for those dashboards. The options are: |
||||
|
||||
<!-- prettier-ignore-start --> |
||||
|
||||
| Option | Description | |
||||
| ------ | ----------- | |
||||
| Source dashboard | Select the dashboard from which you want to generate the report. | |
||||
| [Template variables (optional)](#template-variables) | Select the variable values for the selected dashboard. This option is only displayed if the dashboard has variables. | |
||||
| [Time range (optional)](#time-range) | By default, reports use the saved time range of the dashboard. Optionally, you can change the time range of the report. | |
||||
| Add another dashboard | Add more dashboards to the report. Additional dashboards will be rendered as new pages in the same PDF file, or additional images if you chose to embed images in your report email. You can't add the same dashboard to a report multiple times. | |
||||
|
||||
<!-- prettier-ignore-end --> |
||||
|
||||
#### Template variables |
||||
|
||||
This option is only displayed if the dashboard has variables. |
||||
|
||||
You can configure report-specific template variables for the dashboard on the report page. The variables that you select will override the variables from the dashboard, and they are used when rendering a PDF file of the report. For detailed information about using template variables, refer to the [Templates and variables](ref:templates-and-variables) section. |
||||
|
||||
The query variables saved with a report might become out of date if the results of that query change. For example, if your template variable queries for a list of hostnames and a new hostname is added, then it will not be included in the report. If that occurs, the selected variables must be manually updated in the report. If you select the **All** value for the template variable or if you keep the dashboard's original variable selection, then the report stays up-to-date as new values are added. |
||||
|
||||
#### Time range |
||||
|
||||
By default, reports use the saved time range of the dashboard. Optionally, you can change the time range of the report by: |
||||
|
||||
- Saving a modified time range to the dashboard. Changing the dashboard time range without saving it doesn't change the time zone of the report. |
||||
- Setting a time range via the **Time range** field in the report form. If specified, the custom time range overrides the time range from the report's dashboard. |
||||
|
||||
The page header of the report displays the time range for the dashboard's data queries. |
||||
|
||||
##### Report time zones |
||||
|
||||
Reports use the time zone of the dashboard from which they’re generated. You can control the time zone for your reports by setting the dashboard to a specific time zone. Note that this affects the display of the dashboard for all users. |
||||
|
||||
If a dashboard has the **Browser Time** setting, the reports generated from that dashboard use the time zone of the Grafana server. As a result, this time zone might not match the time zone of users creating or receiving the report. |
||||
|
||||
If the time zone is set differently between your Grafana server and its remote image renderer, then the time ranges in the report might be different between the page header and the time axes in the panels. To avoid this, set the time zone to UTC for dashboards when using a remote renderer. Each dashboard's time zone setting is visible in the [time range controls](ref:time-range-controls). |
||||
|
||||
### 2. Format report |
||||
|
||||
At this step, set the report formatting options. You can select multiple options: |
||||
|
||||
- [Attach the report as a PDF](#attach-the-report-as-a-pdf) |
||||
- [Include table data as PDF appendix](#table-data-in-pdf) (Public preview only) |
||||
- [Embed a dashboard image in the email](#embed-a-dashboard-as-an-image-in-the-email) |
||||
- [Attach a CSV file of the table panel data](#attach-a-csv-file-of-the-table-panel-data) |
||||
- [Attach a separate PDF of table data](#table-data-in-pdf) (Public preview only) |
||||
|
||||
#### Attach the report as a PDF |
||||
|
||||
If you selected the PDF format option, under the **Style the PDF** section, set the following options: |
||||
|
||||
- **Show template variables** - Click the checkbox to select this option. |
||||
- **Orientation** - Set the report orientation in **Portrait** or **Landscape**. Refer to the [Layout and orientation table](#layout-and-orientation) to see examples. |
||||
- **Layout** - Select one of the following: |
||||
- **Simple** - Renders each panel as full-width across the PDF. Refer to the [Layout and orientation table](#layout-and-orientation) to see examples. |
||||
- **Grid** - Renders the PDF with the same panel arrangement and width as the source dashboard. Refer to the [Layout and orientation table](#layout-and-orientation) to see examples. |
||||
- **Zoom** - Zoom in to enlarge text in your PDF, or zoom out to see more data (like table columns) per panel. |
||||
|
||||
Click **Preview PDF** in the top-right corner of the screen to view a rendered PDF with the options you selected. |
||||
|
||||
##### Layout and orientation |
||||
|
||||
<!-- prettier-ignore-start --> |
||||
|
||||
| Layout | Orientation | Description | Preview | |
||||
| ------ | ----------- | --------------------------------------------------------------------------------------------------------- | ------------ | |
||||
| Simple | Portrait | Generates an A4 page in portrait mode with three panels per page. | {{< figure src="/static/img/docs/enterprise/reports_portrait_preview.png" max-width="500px" alt="Simple layout in portrait" >}} | |
||||
| Simple | Landscape | Generates an A4 page in landscape mode with a single panel per page. | {{< figure src="/static/img/docs/enterprise/reports_landscape_preview.png" max-width="500px" alt="Simple layout in landscape" >}} | |
||||
| Grid | Portrait | Generates an A4 page in portrait mode with panels arranged in the same way as at the original dashboard. | {{< figure src="/static/img/docs/enterprise/reports_grid_portrait_preview.png" max-width="500px" alt="Grid layout in portrait" >}} | |
||||
| Grid | Landscape | Generates an A4 page in landscape mode with panels arranged in the same way as in the original dashboard. | {{< figure src="/static/img/docs/enterprise/reports_grid_landscape_preview.png" max-width="500px" alt="Grid layout in landscape" >}} | |
||||
|
||||
<!-- prettier-ignore-end --> |
||||
|
||||
#### Embed a dashboard as an image in the email |
||||
|
||||
You can send a report email with an image of the dashboard embedded in the email instead of attached as a PDF. In this case, the email recipients can see the dashboard at a glance instead of having to open the PDF. |
||||
|
||||
#### Attach a CSV file of the table panel data |
||||
|
||||
{{< admonition type="note" >}} |
||||
To use this feature in Grafana Enterprise, you must have [Grafana image renderer plugin](/grafana/plugins/grafana-image-renderer) v3.0. |
||||
{{< /admonition >}} |
||||
|
||||
You can attach a CSV file to the report email for each table panel on the selected dashboard, along with the PDF report. By default, CSV files larger than 10Mb are not sent, which keeps email servers from rejecting the email. You can increase or decrease this limit in the [reporting configuration](ref:rendering-configuration). |
||||
|
||||
This feature relies on the same plugin that supports the [image rendering](ref:image-rendering) features. |
||||
|
||||
When the CSV file is generated, it is temporarily written to the `csv` folder in the Grafana `data` folder. |
||||
|
||||
A background job runs every 10 minutes and removes temporary CSV files. You can configure how long a CSV file should be stored before being removed by configuring the [temp-data-lifetime](ref:temp-data-lifetime) setting. This setting also affects how long a renderer PNG file should be stored. |
||||
|
||||
Click **Download CSV** in the top-right corner of the screen to see the file. |
||||
|
||||
#### Table data in PDF |
||||
|
||||
{{% admonition type="note" %}} |
||||
Available in public preview (`pdfTables` feature toggle) in [Grafana Enterprise](ref:grafana-enterprise) v10.3+ with the [Grafana image renderer plugin](/grafana/plugins/grafana-image-renderer) v3.0+, as well as [Grafana Cloud](/docs/grafana-cloud/). |
||||
{{% /admonition %}} |
||||
|
||||
When there's more data in your table visualizations than can be shown in the dashboard PDF, you can select one of these two options to access all table visualization data as PDF in your reports: |
||||
|
||||
- **Include table data as PDF appendix** - Adds an appendix to the main dashboard PDF. |
||||
- **Attach a separate PDF of table data** - Generates a separate PDF file. |
||||
|
||||
This feature relies on the same plugin that supports the [image rendering](ref:image-rendering) features. |
||||
|
||||
### 3. Schedule |
||||
|
||||
At this step, set scheduling information. Options vary depending on the frequency you select. |
||||
|
||||
<!-- prettier-ignore-start --> |
||||
|
||||
| Option | Description | |
||||
| ------ | ----------- | |
||||
| Frequency | Scheduled reports can be sent once, or repeated on an hourly, daily, weekly, or monthly basis, or sent at custom intervals. You can also disable scheduling by selecting **Never**, for example to send the report using the API. | |
||||
| Time | Choose one of the following:<ul><li>**Send now** sends the report immediately after you save it. To stop sending the report at some point in the future, add an end date.</li><li>**Send later** schedules a report for a later date. When you select this option, the required **Start date**, **Start time**, and **Time zone** options are displayed.</li></ul> | |
||||
| End date | If you leave the end date empty, the report is sent out indefinitely. | |
||||
| Send only from Monday to Friday | For reports that have an hourly or daily frequency, you can choose to send them only from Monday to Friday. | |
||||
| Send on the last day of the month | When you schedule a report with a monthly frequency, and set the start date between the 29th and the 31st of the month, the report is only sent during the months that have those dates. If you want the report to be sent every month, select this option instead. This way, the report is sent on the last day of every month regardless of how many days there are in any given month. | |
||||
|
||||
<!-- prettier-ignore-end --> |
||||
|
||||
### 4. Share |
||||
|
||||
At this step, enter information related to sharing the report: |
||||
|
||||
<!-- prettier-ignore-start --> |
||||
|
||||
| Option | Description | |
||||
| ------ | ----------- | |
||||
| Report name | Name of the report as you want it to appear in the **Reports** list. The report name also populates the email subject line. | |
||||
| Recipients | Enter the email addresses of the people or teams that you want to receive the report, separated by commas or semicolons. | |
||||
| Reply-to email address | The address that appears in the **Reply to** field of the email. | |
||||
| Message | Message body in the email with the report. | |
||||
| Include a dashboard link | Include a link to the dashboard from within the report email. | |
||||
|
||||
<!-- prettier-ignore-end --> |
||||
|
||||
Click **Send test email** in the top-right corner of the screen to verify that the configuration works as expected and to verify that emails are working. You can choose to send this email to the recipients configured for the report, or to a different set of email addresses only used for testing. The last saved version of the report will be sent to selected emails. |
||||
|
||||
### 5. Confirm |
||||
|
||||
At this step, the confirmation page displays all your the settings. Review them and confirm that they're correct or click the provided **Edit** links for each section to make updates. |
||||
|
||||
Then, click **Send now** or **Schedule send**. |
||||
|
||||
You can also save the report as a draft or discard it. Discarding the report is irreversible. |
||||
|
||||
## Send a report using the API |
||||
|
||||
You can send reports programmatically with the [send report](ref:send-report) endpoint in the [HTTP APIs](ref:http-apis). |
||||
|
||||
## Manage reports |
||||
|
||||
On the **Reports** page, you can view and manage your existing reports or create new ones. |
||||
|
||||
 |
||||
|
||||
### Edit |
||||
|
||||
To edit a report, follow these steps: |
||||
|
||||
1. In the main menu, click **Dashboards > Reporting**. |
||||
1. Click the row of the report you want to update. |
||||
1. Click the **Edit report** button in the top-right hand corner or click the **Edit** link for a specific section to go to that one directly. |
||||
1. When you've finished making changes, click **Confirm** at the top of the screen to go to the last step. |
||||
1. Click **Update report**. |
||||
|
||||
### Pause or resume a report |
||||
|
||||
You can pause and resume sending reports from the report list view. To do this, follow these steps: |
||||
|
||||
1. In the main menu, click **Dashboards > Reporting**. |
||||
1. On the row of the report you want to update, do one of the following: |
||||
|
||||
- Click the pause icon - The report won't be sent according to its schedule until it's resumed. |
||||
- Click the resume icon - The report resumes on its previous schedule. |
||||
|
||||
## Troubleshoot Reporting |
||||
|
||||
To troubleshoot and get more log information, enable debug logging in the configuration file. Refer to [Configuration](ref:configuration) for more information. |
||||
|
||||
```bash |
||||
[log] |
||||
filters = report:debug |
||||
``` |
@ -1,363 +0,0 @@ |
||||
--- |
||||
aliases: |
||||
- ../administration/reports/ # /docs/grafana/latest/administration/reports/ |
||||
- ../enterprise/export-pdf/ # /docs/grafana/latest/enterprise/export-pdf/ |
||||
- ../enterprise/reporting/ # /docs/grafana/latest/enterprise/reporting/ |
||||
- ../panels/create-reports/ # /docs/grafana/latest/panels/create-reports/ |
||||
- reporting/ # /docs/grafana/latest/dashboards/reporting/ |
||||
keywords: |
||||
- grafana |
||||
- reporting |
||||
- export |
||||
- pdf |
||||
labels: |
||||
products: |
||||
- cloud |
||||
- enterprise |
||||
menuTitle: Reporting |
||||
title: Create and manage reports |
||||
description: Generate and share PDF reports from your Grafana dashboards |
||||
weight: 600 |
||||
refs: |
||||
repeat-panels-or-rows: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/panels-visualizations/configure-panel-options/#configure-repeating-rows-or-panels |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana-cloud/visualizations/panels-visualizations/configure-panel-options/#configure-repeating-rows-or-panels |
||||
http-apis: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/developers/http_api/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/developers/http_api/ |
||||
image-rendering: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/image-rendering/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/image-rendering/ |
||||
rbac: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/administration/roles-and-permissions/access-control/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/administration/roles-and-permissions/access-control/ |
||||
permission: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/administration/roles-and-permissions/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/administration/roles-and-permissions/ |
||||
role-based-access-control: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/administration/roles-and-permissions/access-control/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/administration/roles-and-permissions/access-control/ |
||||
configuration: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/ |
||||
image-rendering: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/image-rendering/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/image-rendering/ |
||||
templates-and-variables: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/dashboards/variables/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana-cloud/visualizations/dashboards/variables/ |
||||
grafana-enterprise: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/ |
||||
configuration: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#filters |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#filters |
||||
time-range-controls: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/dashboards/use-dashboards/#set-dashboard-time-range |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana-cloud/visualizations/dashboards/use-dashboards/#set-dashboard-time-range |
||||
send-report: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/developers/http_api/reporting/#send-a-report |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana-cloud/developer-resources/api-reference/http-api/reporting/#send-a-report |
||||
smtp: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#smtp |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#smtp |
||||
temp-data-lifetime: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#temp-data-lifetime |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#temp-data-lifetime |
||||
--- |
||||
|
||||
# Create and manage reports |
||||
|
||||
Reporting enables you to automatically generate PDFs from any of your dashboards and have Grafana email them to interested parties on a schedule. This is available in Grafana Cloud and in Grafana Enterprise. |
||||
|
||||
> If you have [Role-based access control](ref:role-based-access-control) enabled, for some actions you would need to have relevant permissions. |
||||
> Refer to specific guides to understand what permissions are required. |
||||
|
||||
Any changes you make to a dashboard used in a report are reflected the next time the report is sent. For example, if you change the time range in the dashboard, then the time range in the report also changes, unless you've configured a custom time range. |
||||
|
||||
For information about recent improvements to the reporting UI, refer to [Grafana reporting: How we improved the UX in Grafana](https://grafana.com/blog/2022/06/29/grafana-reporting-how-we-improved-the-ux-in-grafana/). |
||||
|
||||
## Requirements |
||||
|
||||
- SMTP must be configured for reports to be sent. Refer to [SMTP](ref:smtp) in [Configuration](ref:configuration) for more information. |
||||
- The Image Renderer plugin must be installed or the remote rendering service must be set up. Refer to [Image rendering](ref:image-rendering) for more information. |
||||
|
||||
## Access control |
||||
|
||||
When [RBAC](ref:rbac) is enabled, you need to have the relevant [Permissions](ref:permission) to create and manage reports. |
||||
|
||||
## Create or update a report |
||||
|
||||
Only organization administrators can create reports by default. You can customize who can create reports with [Role-based access control](ref:role-based-access-control). |
||||
|
||||
1. Click **Dashboards > Reports** in the side navigation menu. |
||||
|
||||
The Reports page allows you to view, create, and update your reports. The report form has a multi-step layout. The steps do not need to be completed in succession and can be skipped over by clicking a step name. |
||||
|
||||
1. Click **+ Create a new report**. |
||||
1. Select report dashboard. |
||||
- **Source dashboard:** Select the dashboard from which you want to generate the report. |
||||
- **Time range:** (optional) Use custom time range for the report. For more information, refer to [Report time range](#report-time-range). |
||||
- **Add another dashboard:** Add more than one dashboard to the report. |
||||
1. Format the report. |
||||
- **Choose format options for the report:** Select at least one option. Attach report as PDF, embed dashboard as an image, or attach CSV file of table panel data. |
||||
- If you selected the PDF format option: |
||||
- Select an orientation for the report: **Portrait** or **Landscape**. |
||||
- Select a layout for the generated report: **Simple** or **Grid**. The simple layout renders each panel as full-width across the PDF. The grid layout renders the PDF with the same panel arrangement and width as the source dashboard. |
||||
- Select a zoom level for the report. Zoom in to enlarge text in your PDF, or zoom out to see more data (like table columns) per panel. |
||||
- Click **Preview PDF** to view a rendered PDF with the options you selected. |
||||
1. Schedule report. |
||||
- Enter scheduling information. Options vary depending on the frequency selected. |
||||
1. Enter report information. All fields are required unless otherwise indicated. |
||||
- **Report name:** Name of the report as you want it to appear in the **Reports** list. The report name populates the email subject line. |
||||
- **Recipients:** Enter the emails of the people or teams that you want to receive the report, separated by commas or semicolons. |
||||
- **Reply to:** (optional) The address that appears in the **Reply to** field of the email. |
||||
- **Message:** (optional) Message body in the email with the report. |
||||
- **Include a dashboard link:** Include a link to the dashboard from within the report email. |
||||
- **Send test email:** To verify that the configuration works as expected. You can choose to send this email to the recipients configured for the report, or to a different set of email addresses only used for testing. |
||||
1. Preview and save the report. |
||||
|
||||
### Save as draft |
||||
|
||||
> **Note:** Available in [Grafana Enterprise](ref:grafana-enterprise) and [Grafana Cloud](/docs/grafana-cloud/). |
||||
|
||||
You can save a report as a draft at any point during the report creation or update process. You can save a report as a draft even if it's missing required fields. Also, the report won't be sent according to its schedule while it's a draft. |
||||
|
||||
### Choose template variables |
||||
|
||||
> **Note:** Available in [Grafana Enterprise](ref:grafana-enterprise) and [Grafana Cloud](/docs/grafana-cloud/). |
||||
|
||||
You can configure report-specific template variables for the dashboard on the report page. The variables that you select will override the variables from the dashboard, and they are used when rendering a PDF file of the report. For detailed information about using template variables, refer to the [Templates and variables](ref:templates-and-variables) section. |
||||
|
||||
{{% admonition type="note" %}} |
||||
The query variables saved with a report might become of date if the results of that query change. For example, if your template variable queries for a list of hostnames and a new hostname is added, then it will not be included in the report. If that occurs, the selected variables must be manually updated in the report. If you select the `All` value for the template variable or if you keep the dashboard's original variable selection, then the report stays up-to-date as new values are added. |
||||
{{% /admonition %}} |
||||
|
||||
### Render a report with panels or rows set to repeat by a variable |
||||
|
||||
> **Note:** Available in [Grafana Enterprise](ref:grafana-enterprise) and [Grafana Cloud](/docs/grafana-cloud/). |
||||
|
||||
You can include dynamic dashboards with panels or rows, set to repeat by a variable, into reports. For detailed information about setting up repeating panels or rows in dashboards, refer to [Repeat panels or rows](ref:repeat-panels-or-rows). |
||||
|
||||
### Report time range |
||||
|
||||
> **Note:** You can set custom report time ranges in [Grafana Enterprise](ref:grafana-enterprise) 7.2+ and [Grafana Cloud](/docs/grafana-cloud/). |
||||
|
||||
By default, reports use the saved time range of the dashboard. You can change the time range of the report by: |
||||
|
||||
- Saving a modified time range to the dashboard. Changing the dashboard time range without saving it doesn't change the time zone of the report. |
||||
- Setting a time range via the **Time range** field in the report form. If specified, the custom time range overrides the time range from the report's dashboard. |
||||
|
||||
The page header of the report displays the time range for the dashboard's data queries. |
||||
|
||||
#### Report time zones |
||||
|
||||
Reports use the time zone of the dashboard from which they’re generated. You can control the time zone for your reports by setting the dashboard to a specific time zone. Note that this affects the display of the dashboard for all users. |
||||
|
||||
If a dashboard has the **Browser Time** setting, the reports generated from that dashboard use the time zone of the Grafana server. As a result, this time zone might not match the time zone of users creating or receiving the report. |
||||
|
||||
If the time zone is set differently between your Grafana server and its remote image renderer, then the time ranges in the report might be different between the page header and the time axes in the panels. To avoid this, set the time zone to UTC for dashboards when using a remote renderer. Each dashboard's time zone setting is visible in the [time range controls](ref:time-range-controls). |
||||
|
||||
### Layout and orientation |
||||
|
||||
| Layout | Orientation | Support | Description | Preview | |
||||
| ------ | ----------- | ------- | --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
||||
| Simple | Portrait | v6.4+ | Generates an A4 page in portrait mode with three panels per page. | {{< figure src="/static/img/docs/enterprise/reports_portrait_preview.png" max-width="500px" max-height="500px" class="docs-image--no-shadow" alt="Simple layout in portrait" >}} | |
||||
| Simple | Landscape | v6.7+ | Generates an A4 page in landscape mode with a single panel per page. | {{< figure src="/static/img/docs/enterprise/reports_landscape_preview.png" max-width="500px" class="docs-image--no-shadow" alt="Simple layout in landscape" >}} | |
||||
| Grid | Portrait | v7.2+ | Generates an A4 page in portrait mode with panels arranged in the same way as at the original dashboard. | {{< figure src="/static/img/docs/enterprise/reports_grid_portrait_preview.png" max-width="500px" max-height="500px" class="docs-image--no-shadow" alt="Grid layout in portrait" >}} | |
||||
| Grid | Landscape | v7.2+ | Generates an A4 page in landscape mode with panels arranged in the same way as in the original dashboard. | {{< figure src="/static/img/docs/enterprise/reports_grid_landscape_preview.png" max-width="500px" class="docs-image--no-shadow" alt="Grid layout in landscape" >}} | |
||||
|
||||
### CSV export |
||||
|
||||
> **Note:** Available in [Grafana Enterprise](ref:grafana-enterprise) 8+ with the [Grafana image renderer plugin](/grafana/plugins/grafana-image-renderer) v3.0+, and [Grafana Cloud](/docs/grafana-cloud/). |
||||
|
||||
You can attach a CSV file to the report email for each table panel on the selected dashboard, along with the PDF report. By default, CSVs larger than 10Mb are not sent which keeps email servers from rejecting the email. You can increase or decrease this limit in the [reporting configuration](#rendering-configuration). |
||||
|
||||
This feature relies on the same plugin that supports the [image rendering](ref:image-rendering) features. |
||||
|
||||
When the CSV file is generated, it is temporarily written to the `csv` folder in the Grafana `data` folder. |
||||
|
||||
A background job runs every 10 minutes and removes temporary CSV files. You can configure how long a CSV file should be stored before being removed by configuring the [temp-data-lifetime](ref:temp-data-lifetime) setting. This setting also affects how long a renderer PNG file should be stored. |
||||
|
||||
### Table data in PDF |
||||
|
||||
{{% admonition type="note" %}} |
||||
Available in public preview (`pdfTables` feature toggle) in [Grafana Enterprise](ref:grafana-enterprise) v10.3+ with the [Grafana image renderer plugin](/grafana/plugins/grafana-image-renderer) v3.0+, and [Grafana Cloud](/docs/grafana-cloud/). |
||||
{{% /admonition %}} |
||||
|
||||
When there's more data in your table visualizations than can be shown in the dashboard PDF, you can select one of these two options to access all table visualization data as PDF in your reports: |
||||
|
||||
- **Include table data as PDF appendix** - Adds an appendix to the main dashboard PDF. |
||||
- **Attach a separate PDF of table data** - Generates a separate PDF file. |
||||
|
||||
This feature relies on the same plugin that supports the [image rendering](ref:image-rendering) features. |
||||
|
||||
### Scheduling |
||||
|
||||
> **Note:** Available in [Grafana Enterprise](ref:grafana-enterprise) and [Grafana Cloud](/docs/grafana-cloud/). |
||||
|
||||
Scheduled reports can be sent once, or repeated on an hourly, daily, weekly, or monthly basis, or sent at custom intervals. You can also disable scheduling by selecting **Never**, for example to send the report via the API. |
||||
|
||||
**Send now or schedule for later** |
||||
|
||||
- **Send now** sends the report immediately after you save it. To stop sending the report at some point in the future, add an end date. If you leave the end date empty, the report is sent out indefinitely. |
||||
|
||||
- **Send later** schedules a report for a later date. Thus, the start date and time are required fields. If you leave the end date empty, the report is sent out indefinitely. |
||||
|
||||
**Send only from Monday to Friday** |
||||
|
||||
For reports that have an hourly or daily frequency, you can choose to send them only from Monday to Friday. |
||||
|
||||
**Send on the last day of the month** |
||||
|
||||
When you schedule a report with a monthly frequency, and set the start date between the 29th and the 31st of the month, the report is only sent during the months that have those dates. If you want the report to be sent every month, select the **Send on the last day of the month** option instead. This way, the report is sent on the last day of every month regardless of how many days there are in any given month. |
||||
|
||||
#### Send a test email |
||||
|
||||
> **Note:** Available in [Grafana Enterprise](ref:grafana-enterprise) and [Grafana Cloud](/docs/grafana-cloud/). |
||||
|
||||
1. In the report, click **Send test email**. |
||||
1. In the **Email** field, enter the email address or addresses that you want to test, separated by a semicolon. |
||||
If you want to use email addresses from the report, then select the **Use emails from report** check box. |
||||
1. Click **Send**. |
||||
|
||||
The last saved version of the report will be sent to selected emails. You can use this to verify emails are working and to make sure the report is generated and displayed as you expect. |
||||
|
||||
### Pause a report |
||||
|
||||
> **Note:** Available in [Grafana Enterprise](ref:grafana-enterprise) and [Grafana Cloud](/docs/grafana-cloud/). |
||||
|
||||
You can pause sending reports from the report list view by clicking the pause icon. The report will not be sent according to its schedule until it is resumed by clicking the resume button on the report row. |
||||
|
||||
### Add multiple dashboards to a report |
||||
|
||||
> **Note:** Available in [Grafana Enterprise](ref:grafana-enterprise) and [Grafana Cloud](/docs/grafana-cloud/). |
||||
|
||||
You can add more than one dashboard to a report. Additional dashboards will be rendered as new pages in the same PDF file, or additional images if you chose to embed images in your report email. You cannot add the same dashboard to a report multiple times. |
||||
|
||||
### Embed a dashboard as an image into a report |
||||
|
||||
> **Note:** Available in [Grafana Enterprise](ref:grafana-enterprise) and [Grafana Cloud](/docs/grafana-cloud/). |
||||
|
||||
You can send a report email with an image of the dashboard embedded in the email instead of attached as a PDF. In this case, the email recipients can see the dashboard at a glance instead of having to open the PDF. |
||||
|
||||
## Export dashboard as PDF |
||||
|
||||
You can generate and save PDF files of any dashboard. |
||||
|
||||
> **Note:** Available in [Grafana Enterprise](ref:grafana-enterprise) and [Grafana Cloud](/docs/grafana-cloud/). |
||||
|
||||
1. In the dashboard that you want to export as PDF, click the **Share** button. |
||||
1. On the PDF tab, select a layout option for the exported dashboard: **Portrait** or **Landscape**. |
||||
1. Click **Save as PDF** to render the dashboard as a PDF file. |
||||
|
||||
Grafana opens the PDF file in a new window or browser tab. |
||||
|
||||
## Send a report via the API |
||||
|
||||
You can send reports programmatically with the [send report](ref:send-report) endpoint in the [HTTP APIs](ref:http-apis). |
||||
|
||||
## Rendering configuration |
||||
|
||||
When generating reports, each panel renders separately before being collected in a PDF. You can configure the per-panel rendering timeout and number of concurrently rendered panels. |
||||
|
||||
To make a panel more legible, you can set a scale factor for the rendered images. However, a higher scale factor increases the file size of the generated PDF. |
||||
|
||||
You can also specify custom fonts that support different Unicode scripts. The DejaVu font is the default used for PDF rendering. |
||||
|
||||
These options are available in the [configuration](ref:configuration) file. |
||||
|
||||
```ini |
||||
[reporting] |
||||
# Use this option to enable or disable the reporting feature. When disabled, no reports are generated, and the UI is hidden. By default, reporting is enabled. |
||||
enabled = true |
||||
# Set timeout for the following reporting rendering requests: generating PDFs, generating embedded dashboard images for report emails, and generating attached CSV files. |
||||
rendering_timeout = 10s |
||||
# Set maximum number of concurrent calls to the rendering service |
||||
concurrent_render_limit = 4 |
||||
# Set the 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 |
||||
image_scale_factor = 2 |
||||
# Set the maximum file size in megabytes for the report email attachments |
||||
max_attachment_size_mb = 10 |
||||
# Path to the directory containing font files |
||||
fonts_path = |
||||
# Name of the TrueType font file with regular style |
||||
font_regular = DejaVuSansCondensed.ttf |
||||
# Name of the TrueType font file with bold style |
||||
font_bold = DejaVuSansCondensed-Bold.ttf |
||||
# Name of the TrueType font file with italic style |
||||
font_italic = DejaVuSansCondensed-Oblique.ttf |
||||
# 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. |
||||
max_retries_per_panel = 3 |
||||
# Allowed domains to receive reports. Use an asterisk (`*`) to allow all domains. Use a comma-separated list to allow multiple domains. Example: allowed_domains = grafana.com, example.org |
||||
allowed_domains = * |
||||
``` |
||||
|
||||
## Report settings |
||||
|
||||
> **Note:** Available in [Grafana Enterprise](ref:grafana-enterprise) and [Grafana Cloud](/docs/grafana-cloud/). |
||||
|
||||
You can configure organization-wide report settings in the **Settings** under **Dashboards > Reporting**. Settings are applied to all the reports for current organization. |
||||
|
||||
You can customize the branding options. |
||||
|
||||
### Attachment settings |
||||
|
||||
#### PDF |
||||
|
||||
- **Company logo:** Company logo displayed in the report PDF. It can be configured by specifying a URL, or by uploading a file. The maximum file size is 16 MB. Defaults to the Grafana logo. |
||||
|
||||
- **Theme:** Theme of the PDF attached to the report. Defaults to **Light**. The selected theme is also applied to the PDFs generated when you click **Preview PDF** during report creation or select the **Export as PDF** option on a dashboard. If **Current** is selected, the PDF in the report will be in the Admin's instance theme, but the preview and exported PDFs will be in the user's instance theme. |
||||
|
||||
#### Embedded Image |
||||
|
||||
- **Theme:** Theme of the dashboard image embedded in the email. Defaults to **Dark**. |
||||
|
||||
### Email branding |
||||
|
||||
- **Company logo:** Company logo displayed in the report email. It can be configured by specifying a URL, or by uploading a file. The maximum file size is 16 MB. Defaults to the Grafana logo. |
||||
- **Email footer:** Toggle to enable the report email footer. Select **Sent by** or **None**. |
||||
- **Footer link text:** Text of the link in the report email footer. Defaults to `Grafana`. |
||||
- **Footer link URL:** Link of the report email footer. |
||||
|
||||
Currently, the API does not allow for the simultaneous upload of files with identical names for both the email logo and report logo. You can still upload the same file for each logo separately in two distinct steps. |
||||
|
||||
## Troubleshoot reporting |
||||
|
||||
To troubleshoot and get more log information, enable debug logging in the configuration file. Refer to [Configuration](ref:configuration) for more information. |
||||
|
||||
```bash |
||||
[log] |
||||
filters = report:debug |
||||
``` |
@ -0,0 +1,56 @@ |
||||
--- |
||||
keywords: |
||||
- grafana |
||||
- reporting |
||||
- settings |
||||
labels: |
||||
products: |
||||
- cloud |
||||
- enterprise |
||||
menuTitle: Settings |
||||
title: Reporting settings |
||||
description: Manage organizational Reporting settings |
||||
weight: 700 |
||||
refs: |
||||
grafana-enterprise: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/ |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/introduction/grafana-enterprise/ |
||||
configuration: |
||||
- pattern: /docs/grafana/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#filters |
||||
- pattern: /docs/grafana-cloud/ |
||||
destination: /docs/grafana/<GRAFANA_VERSION>/setup-grafana/configure-grafana/#filters |
||||
--- |
||||
|
||||
# Reporting settings |
||||
|
||||
You can configure organization-wide report settings and branding options in **Dashboards > Reporting > Settings**. Settings are applied to all the reports for the current organization. |
||||
|
||||
## Attachment settings |
||||
|
||||
The options in this section control the branding and theming of the report attachments. |
||||
|
||||
### PDF |
||||
|
||||
- **Company logo** - Company logo displayed in the report PDF. It can be configured by specifying a URL, or by uploading a file. The maximum file size is 16 MB. Defaults to the Grafana logo. |
||||
|
||||
- **Theme** - Theme of the PDF attached to the report. Defaults to **Light**. The selected theme is also applied to the PDFs generated when you click **Preview PDF** during report creation or select the **Export as PDF** option on a dashboard. If **Current** is selected, the PDF in the report will be in the instance theme of the Admin, but the preview and exported PDFs will be in the user's instance theme. |
||||
|
||||
### Embedded Image |
||||
|
||||
- **Theme** - Theme of the dashboard image embedded in the email. Defaults to **Dark**. |
||||
|
||||
<!-- vale Grafana.WordList = NO --> |
||||
|
||||
## Email branding |
||||
|
||||
<!-- vale Grafana.WordList = YES --> |
||||
|
||||
- **Company logo** - Company logo displayed in the report email. It can be configured by specifying a URL, or by uploading a file. The maximum file size is 16 MB. Defaults to the Grafana logo. |
||||
- **Email footer** - Toggle to enable the report email footer. Select **Sent by** or **None**. |
||||
- **Footer link text** - Text of the link in the report email footer. Defaults to `Grafana`. |
||||
- **Footer link URL** - Link of the report email footer. |
||||
|
||||
Currently, the API does not allow for the simultaneous upload of files with identical names for both the email logo and report logo. You can still upload the same file for each logo separately in two distinct steps. |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@ |
||||
--- |
||||
title: Axis options |
||||
comments: | |
||||
This file is used in the following visualizations: time series. |
||||
--- |
||||
|
||||
Options under the **Axis** section control how the x- and y-axes are rendered. Some options don't take effect until you click outside of the field option box you're editing. You can also press `Enter`. |
||||
|
||||
| Option | Description | |
||||
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------ | |
||||
| Time zone | Set the desired time zones to display along the x-axis. | |
||||
| [Placement](#placement) | Select the placement of the y-axis. | |
||||
| Label | Set a y-axis text label. If you have more than one y-axis, then you can assign different labels using an override. | |
||||
| Width | Set a fixed width for the axis. By default, Grafana dynamically calculates the width of an axis. | |
||||
| Show grid lines | Set the axis grid line visibility.<br> | |
||||
| Color | Set the color of the axis. | |
||||
| Show border | Set the axis border visibility. | |
||||
| Scale | Set the y-axis values scale.<br> | |
||||
| Centered zero | Set the y-axis so it's centered on zero. | |
||||
| [Soft min](#soft-min-and-soft-max) | Set a soft min to better control the y-axis limits. zero. | |
||||
| [Soft max](#soft-min-and-soft-max) | Set a soft max to better control the y-axis limits. zero. | |
@ -0,0 +1,10 @@ |
||||
--- |
||||
title: Axis options |
||||
comments: | |
||||
This file is used in the following visualizations: state timeline, status history. |
||||
--- |
||||
|
||||
| Option | Description | |
||||
| --------- | ------------------------------------------------------------------------------------------------ | |
||||
| Placement | Control the visibility of series names along the y-axis or time values along the x-axis. | |
||||
| Width | Set a fixed width for the axis. By default, Grafana dynamically calculates the width of an axis. | |
@ -0,0 +1,87 @@ |
||||
import * as e2e from '@grafana/e2e-selectors'; |
||||
import { expect, test } from '@grafana/plugin-e2e'; |
||||
|
||||
test.describe('Loki editor', () => { |
||||
test('Autocomplete features should work as expected.', async ({ page }) => { |
||||
// Go to loki datasource in explore
|
||||
await page.goto( |
||||
'/explore?schemaVersion=1&panes=%7B%22iap%22:%7B%22datasource%22:%22gdev-loki%22,%22queries%22:%5B%7B%22refId%22:%22A%22,%22expr%22:%22%22,%22queryType%22:%22range%22,%22datasource%22:%7B%22type%22:%22loki%22,%22uid%22:%22gdev-loki%22%7D,%22editorMode%22:%22code%22%7D%5D,%22range%22:%7B%22from%22:%22now-1h%22,%22to%22:%22now%22%7D%7D%7D&orgId=1' |
||||
); |
||||
|
||||
const queryEditor = page.getByTestId(e2e.selectors.components.QueryField.container); |
||||
const queryEditorRows = page.getByTestId('query-editor-rows'); |
||||
|
||||
async function assertQueryEditorEmpty() { |
||||
const queryEditorEmptyText = /^Enter to Rename.+/; |
||||
await expect(queryEditor).toHaveText(queryEditorEmptyText); |
||||
} |
||||
|
||||
async function clearInput() { |
||||
// Clear focused input
|
||||
// Monaco appears to need some time to init keybindings after a change, adding this timeout to prevent flake
|
||||
await page.waitForTimeout(100); |
||||
await page.keyboard.press('ControlOrMeta+A'); |
||||
await page.keyboard.press('Backspace'); |
||||
} |
||||
|
||||
// assert that the query builder is shown by default
|
||||
await expect(page.getByText('Label filters')).toHaveCount(1); |
||||
|
||||
// switch to code editor
|
||||
await page.getByLabel('Code').click(); |
||||
|
||||
await page.waitForFunction(() => window.monaco); |
||||
await expect(queryEditor).toHaveCount(1); |
||||
await assertQueryEditorEmpty(); |
||||
|
||||
// assert editor automatically adds close paren
|
||||
await queryEditor.click(); |
||||
await page.keyboard.type('time('); |
||||
await expect(queryEditor).toContainText('time()'); |
||||
|
||||
// removes closing brace when opening brace is removed
|
||||
await clearInput(); |
||||
await assertQueryEditorEmpty(); |
||||
await page.keyboard.type('avg_over_time('); |
||||
await expect(queryEditor).toContainText('avg_over_time()'); |
||||
await page.keyboard.press('Backspace'); |
||||
await expect(queryEditor).not.toContainText('avg_over_time()'); |
||||
await expect(queryEditor).toContainText('avg_over_time'); |
||||
|
||||
// keeps closing brace when opening brace is removed and inner values exist
|
||||
await clearInput(); |
||||
await assertQueryEditorEmpty(); |
||||
await page.keyboard.type('time(test'); |
||||
await page.keyboard.press('ArrowLeft'); |
||||
await page.keyboard.press('ArrowLeft'); |
||||
await page.keyboard.press('ArrowLeft'); |
||||
await page.keyboard.press('ArrowLeft'); |
||||
await page.keyboard.press('Backspace'); |
||||
await expect(queryEditor).toContainText('timetest'); |
||||
|
||||
// overrides an automatically inserted paren
|
||||
await clearInput(); |
||||
await assertQueryEditorEmpty(); |
||||
await page.keyboard.type('time()'); |
||||
await expect(queryEditor).toContainText('time()'); |
||||
|
||||
// does not override manually inserted braces
|
||||
await clearInput(); |
||||
await assertQueryEditorEmpty(); |
||||
await page.keyboard.type('))'); |
||||
await expect(queryEditor).toContainText('))'); |
||||
|
||||
// Should execute the query when enter with shift is pressed
|
||||
await clearInput(); |
||||
await assertQueryEditorEmpty(); |
||||
await page.keyboard.press('Shift+Enter'); |
||||
await expect(page.getByTestId('explore-no-data')).toHaveCount(1); |
||||
|
||||
// Suggestions plugin
|
||||
await clearInput(); |
||||
await assertQueryEditorEmpty(); |
||||
await page.keyboard.type('av'); |
||||
await expect(queryEditorRows.getByLabel(/avg, docs:/)).toHaveCount(1); |
||||
await expect(queryEditorRows.getByLabel(/avg_over_time, docs:/)).toHaveCount(1); |
||||
}); |
||||
}); |
@ -1,88 +0,0 @@ |
||||
import { e2e } from '../utils'; |
||||
import { waitForMonacoToLoad } from '../utils/support/monaco'; |
||||
|
||||
const dataSourceName = 'LokiEditor'; |
||||
const addDataSource = () => { |
||||
e2e.flows.addDataSource({ |
||||
type: 'Loki', |
||||
expectedAlertMessage: 'Unable to connect with Loki. Please check the server logs for more details.', |
||||
name: dataSourceName, |
||||
form: () => { |
||||
cy.get('#connection-url').type('http://loki-url:3100'); |
||||
}, |
||||
}); |
||||
}; |
||||
|
||||
describe('Loki Query Editor', () => { |
||||
beforeEach(() => { |
||||
e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD')); |
||||
}); |
||||
|
||||
afterEach(() => { |
||||
e2e.flows.revertAllChanges(); |
||||
}); |
||||
|
||||
it('Autocomplete features should work as expected.', () => { |
||||
addDataSource(); |
||||
|
||||
cy.intercept(/labels?/, (req) => { |
||||
req.reply({ status: 'success', data: ['instance', 'job', 'source'] }); |
||||
}); |
||||
|
||||
cy.intercept(/series?/, (req) => { |
||||
req.reply({ status: 'success', data: [{ instance: 'instance1' }] }); |
||||
}); |
||||
|
||||
// Go to Explore and choose Loki data source
|
||||
e2e.pages.Explore.visit(); |
||||
e2e.components.DataSourcePicker.container().should('be.visible').click(); |
||||
cy.contains(dataSourceName).scrollIntoView().should('be.visible').click(); |
||||
|
||||
e2e.components.RadioButton.container().filter(':contains("Code")').click(); |
||||
|
||||
waitForMonacoToLoad(); |
||||
|
||||
// adds closing braces around empty value
|
||||
e2e.components.QueryField.container().type('time('); |
||||
cy.get('.monaco-editor textarea:first').should(($el) => { |
||||
expect($el.val()).to.eq('time()'); |
||||
}); |
||||
|
||||
// removes closing brace when opening brace is removed
|
||||
e2e.components.QueryField.container().type('{selectall}{backspace}avg_over_time({backspace}'); |
||||
cy.get('.monaco-editor textarea:first').should(($el) => { |
||||
expect($el.val()).to.eq('avg_over_time'); |
||||
}); |
||||
|
||||
// keeps closing brace when opening brace is removed and inner values exist
|
||||
e2e.components.QueryField.container().type( |
||||
'{selectall}{backspace}time(test{leftArrow}{leftArrow}{leftArrow}{leftArrow}{backspace}' |
||||
); |
||||
cy.get('.monaco-editor textarea:first').should(($el) => { |
||||
expect($el.val()).to.eq('timetest)'); |
||||
}); |
||||
|
||||
// overrides an automatically inserted brace
|
||||
e2e.components.QueryField.container().type('{selectall}{backspace}time()'); |
||||
cy.get('.monaco-editor textarea:first').should(($el) => { |
||||
expect($el.val()).to.eq('time()'); |
||||
}); |
||||
|
||||
// does not override manually inserted braces
|
||||
e2e.components.QueryField.container().type('{selectall}{backspace}))'); |
||||
cy.get('.monaco-editor textarea:first').should(($el) => { |
||||
expect($el.val()).to.eq('))'); |
||||
}); |
||||
|
||||
/** Runner plugin */ |
||||
|
||||
// Should execute the query when enter with shift is pressed
|
||||
e2e.components.QueryField.container().type('{selectall}{backspace}{shift+enter}'); |
||||
cy.get('[data-testid="explore-no-data"]').should('be.visible'); |
||||
|
||||
/** Suggestions plugin */ |
||||
e2e.components.QueryField.container().type('{selectall}av'); |
||||
cy.contains('avg').should('be.visible'); |
||||
cy.contains('avg_over_time').should('be.visible'); |
||||
}); |
||||
}); |
@ -0,0 +1,8 @@ |
||||
include ../.bingo/Variables.mk |
||||
|
||||
.PHONY: all |
||||
all: dashboards |
||||
|
||||
.PHONY: dashboards |
||||
dashboards: $(COG) ## Dashboards – Typescript
|
||||
@$(COG) generate --config ./dashboard-ts.yaml
|
@ -0,0 +1,22 @@ |
||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/grafana/cog/main/schemas/pipeline.json |
||||
|
||||
inputs: |
||||
- cue: |
||||
entrypoint: '%__config_dir%/../packages/grafana-schema/src/schema/dashboard/v2alpha0' |
||||
metadata: |
||||
kind: core |
||||
cue_imports: |
||||
- '%__config_dir%/../packages/grafana-schema/src/common:github.com/grafana/grafana/packages/grafana-schema/src/common' |
||||
|
||||
output: |
||||
directory: '%__config_dir%/../packages/grafana-schema/src/schema/dashboard/' |
||||
|
||||
types: true |
||||
|
||||
languages: |
||||
- typescript: |
||||
skip_runtime: true |
||||
enums_as_union_types: true |
||||
path_prefix: "" |
||||
packages_import_map: |
||||
common: '@grafana/schema' |
@ -1,53 +0,0 @@ |
||||
//go:generate go run gen.go
|
||||
|
||||
package main |
||||
|
||||
import ( |
||||
"context" |
||||
"os" |
||||
|
||||
"github.com/grafana/cog" |
||||
) |
||||
|
||||
type codegenTargets struct { |
||||
modulePath string |
||||
outputPath string |
||||
cueImportsMap map[string]string |
||||
packagesImportMap map[string]string |
||||
} |
||||
|
||||
func main() { |
||||
targets := []codegenTargets{ |
||||
{ |
||||
modulePath: "../packages/grafana-schema/src/schema/dashboard/v2alpha0/", |
||||
outputPath: "../packages/grafana-schema/src/schema/dashboard/v2alpha0/dashboard.gen.ts", |
||||
cueImportsMap: map[string]string{ |
||||
"github.com/grafana/grafana/packages/grafana-schema/src/common": "../packages/grafana-schema/src/common", |
||||
}, |
||||
packagesImportMap: map[string]string{ |
||||
"common": "@grafana/schema", |
||||
}, |
||||
}, |
||||
} |
||||
|
||||
for _, target := range targets { |
||||
codegenPipeline := cog.TypesFromSchema(). |
||||
CUEModule( |
||||
target.modulePath, |
||||
cog.CUEImports(target.cueImportsMap), |
||||
). |
||||
Typescript(cog.TypescriptConfig{ |
||||
ImportsMap: target.packagesImportMap, |
||||
EnumsAsUnionTypes: true, |
||||
}) |
||||
|
||||
files, err := codegenPipeline.Run(context.Background()) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
if err := os.WriteFile(target.outputPath, files[0].Data, 0644); err != nil { |
||||
panic(err) |
||||
} |
||||
} |
||||
} |
@ -1,45 +0,0 @@ |
||||
module github.com/grafana/grafana/kindsv2 |
||||
|
||||
go 1.23.1 |
||||
|
||||
require github.com/grafana/cog v0.0.12 |
||||
|
||||
require ( |
||||
cuelabs.dev/go/oci/ociregistry v0.0.0-20240906074133-82eb438dd565 // indirect |
||||
cuelang.org/go v0.11.1 // indirect |
||||
github.com/cockroachdb/apd/v3 v3.2.1 // indirect |
||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect |
||||
github.com/emicklei/proto v1.13.2 // indirect |
||||
github.com/expr-lang/expr v1.16.9 // indirect |
||||
github.com/getkin/kin-openapi v0.128.0 // indirect |
||||
github.com/go-openapi/jsonpointer v0.21.0 // indirect |
||||
github.com/go-openapi/swag v0.23.0 // indirect |
||||
github.com/google/go-cmp v0.6.0 // indirect |
||||
github.com/google/uuid v1.6.0 // indirect |
||||
github.com/grafana/codejen v0.0.4-0.20230321061741-77f656893a3d // indirect |
||||
github.com/hashicorp/errwrap v1.1.0 // indirect |
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect |
||||
github.com/huandu/xstrings v1.5.0 // indirect |
||||
github.com/invopop/yaml v0.3.1 // indirect |
||||
github.com/josharian/intern v1.0.0 // indirect |
||||
github.com/lib/pq v1.10.9 // indirect |
||||
github.com/mailru/easyjson v0.7.7 // indirect |
||||
github.com/mitchellh/go-wordwrap v1.0.1 // indirect |
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect |
||||
github.com/opencontainers/go-digest v1.0.0 // indirect |
||||
github.com/opencontainers/image-spec v1.1.0 // indirect |
||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect |
||||
github.com/perimeterx/marshmallow v1.1.5 // indirect |
||||
github.com/protocolbuffers/txtpbfmt v0.0.0-20241112170944-20d2c9ebc01d // indirect |
||||
github.com/rogpeppe/go-internal v1.13.1 // indirect |
||||
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect |
||||
github.com/ugorji/go/codec v1.2.11 // indirect |
||||
github.com/yalue/merged_fs v1.3.0 // indirect |
||||
golang.org/x/mod v0.22.0 // indirect |
||||
golang.org/x/net v0.34.0 // indirect |
||||
golang.org/x/oauth2 v0.24.0 // indirect |
||||
golang.org/x/sync v0.10.0 // indirect |
||||
golang.org/x/text v0.21.0 // indirect |
||||
golang.org/x/tools v0.29.0 // indirect |
||||
gopkg.in/yaml.v3 v3.0.1 // indirect |
||||
) |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue