实战 Grafana iFrame 嵌入配置调教

如何将Grafana Dashboard以iFrame形式嵌入第三方页面?

开放匿名访问并限制权限, 在默认配置路径/etc/grafana/grafana.ini下的[auth.anonymous]修改为如下配置,

[auth.anonymous]
# enable anonymous access
enabled = true

# specify organization name that should be used for unauthenticated users
org_name = Main Org.

# specify role for unauthenticated users
org_role = Viewer

在上述默认配置路径的[security]中允许使用嵌入

[security]
# set to true if you want to allow browsers to render Grafana in a <frame>, <iframe>, <embed> or <object>. default is false.
allow_embedding = true

grafana configmap.yaml 配置:

apiVersion: v1
kind: ConfigMap
metadata:
  name: prometheus-stack-grafana
  namespace: kube-prometheus-stack
  selfLink: /api/v1/namespaces/kube-prometheus-stack/configmaps/prometheus-stack-grafana
  uid: fb51211e-a3a0-40de-a13b-24a3425f047c
  resourceVersion: '76452138'
  creationTimestamp: '2023-09-11T02:03:57Z'
  labels:
    app.kubernetes.io/instance: prometheus-stack
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: grafana
    app.kubernetes.io/version: 10.0.1
    helm.sh/chart: grafana-6.58.2
    k8slens-edit-resource-version: v1
  annotations:
    meta.helm.sh/release-name: prometheus-stack
    meta.helm.sh/release-namespace: kube-prometheus-stack
data:
  grafana.ini: |
    [analytics]
    check_for_updates = true
    [grafana_net]
    url = https://grafana.net
    [log]
    mode = console
    [paths]
    data = /var/lib/grafana/
    logs = /var/log/grafana
    plugins = /var/lib/grafana/plugins
    provisioning = /etc/grafana/provisioning
    [server]
    domain = grafana.kube.demo.com

    # 允许匿名访问
    [auth.anonymous]
    enabled = true
    org_name = Main Org.
    org_role = Viewer

    # 允许嵌入,解决前端跨域问题
    [security]
    allow_embedding = true

相关文章:
实战Grafana iFrame嵌入配置调教以及绘制各种图形技巧

为者常成,行者常至