gpt4 book ai didi

kubernetes - 如何为数据源创建grafana configmap?

转载 作者:行者123 更新时间:2023-12-04 11:38:16 25 4
gpt4 key购买 nike

我正在尝试使用 Kube-Prometheus-Stack helm chart https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack 中的 Grafana 实例为 Grafana 数据源创建配置映射
我知道仪表板,您可以使用此答案中列出的命令从 json 文件创建配置映射:stable/prometheus-operator - adding persistent grafana dashboards

wget https://raw.githubusercontent.com/percona/grafana-dashboards/master/dashboards/MongoDB_Overview.json
kubectl -n monitoring create cm grafana-mongodb-overview --from-file=MongoDB_Overview.json
kubectl -n monitoring label cm grafana-mongodb-overview grafana_dashboard=mongodb-overview
可以为 grafana 数据源做类似的事情吗?我目前有一个 datasource.yaml,其中包含以下几行:
    data:
datasource-PRF1-Prometheus.yaml: |-
apiVersion: 1
datasources:
- name: Test-Prometheus
type: prometheus
url: https://prometheus.url.net/
access: Server
isDefault: true
basicAuth: true
basicAuthPassword: password
basicAuthUser: admin
但是,我无法使用它导入数据源,即使它创建了一个配置映射。

最佳答案

要通过 grafana 服务器组件加载数据,您需要在元数据字段中进行设置 grafana_datasource: "1" .
对于配置映射:

apiVersion: v1
kind: ConfigMap
metadata:
name: example-grafana-datasource
labels:
grafana_datasource: "1"
namespace: monitoring
data:
datasource.yaml: |-
apiVersion: 1
datasources:
- access: proxy
basicAuth: false
editable: false
isDefault: false
jsonData:
authType: credentials
defaultRegion: us-west-2
name: CloudWatch
type: cloudwatch
对于具有相同标签的 secret
apiVersion: v1
kind: Secret
metadata:
name: influx-grafana-datasource
labels:
grafana_datasource: "1"
namespace: monitoring
type: Opaque
stringData:
influxdatasource.yaml: |-
# config file version
apiVersion: 1
datasources:
- name: influxdb
type: influxdb
access: proxy
database: metrics_db
user: metrics_read_user
url: http://influx.example.com:8086/
jsonData:
timeInterval: "15s"
secureJsonData:
password: yourinfluxpassword

关于kubernetes - 如何为数据源创建grafana configmap?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64780159/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com