grafana - Grafana 正在使用基本 URL 生成链接:http://localhost:3000 而不是使用我的 url
问题描述
我用 Kubernetes 部署了 grafana 7,这是我的部署:
apiVersion: apps/v1
kind: Deployment
metadata:
name: grafana-core
namespace: monitoring
labels:
app: grafana
component: core
spec:
selector:
matchLabels:
app: grafana
replicas: 1
template:
metadata:
labels:
app: grafana
component: core
spec:
initContainers:
- name: init-chown-data
image: grafana/grafana:7.0.3
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: 0
command: ["chown", "-R", "472:472", "/var/lib/grafana"]
volumeMounts:
- name: grafana-persistent-storage
mountPath: /var/lib/grafana
containers:
- image: grafana/grafana:7.0.3
name: grafana-core
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: 472
# env:
envFrom:
- secretRef:
name: grafana-env
env:
# The following env variables set up basic auth twith the default admin user and admin password.
- name: GF_INSTALL_PLUGINS
value: grafana-clock-panel,grafana-simple-json-datasource,camptocamp-prometheus-alertmanager-datasource
- name: GF_AUTH_BASIC_ENABLED
value: "true"
- name: GF_SECURITY_ADMIN_USER
valueFrom:
secretKeyRef:
name: grafana
key: admin-username
- name: GF_SECURITY_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: grafana
key: admin-password
- name: GF_AUTH_ANONYMOUS_ENABLED
value: "false"
readinessProbe:
httpGet:
path: /login
port: 3000
initialDelaySeconds: 30
timeoutSeconds: 1
volumeMounts:
- name: grafana-persistent-storage
mountPath: /var/lib/grafana
- name: grafana-datasources
mountPath: /etc/grafana/provisioning/datasources
volumes:
- name: grafana-persistent-storage
persistentVolumeClaim:
claimName: grafana-storage
- name: grafana-datasources
configMap:
name: grafana-datasources
nodeSelector:
kops.k8s.io/instancegroup: monitoring-nodes
它运行良好,但每次生成 URL 时,都会使用基本 url:http://localhost:3000 而不是使用https://grafana.company.com
我在哪里可以配置?我找不到处理它的环境变量。
解决方案
将 Grafana 配置文件或环境变量中的root_url
选项配置为.[server]
GF_SERVER_ROOT_URL
https://grafana.company.com/
推荐阅读
- c++ - 如何在 C++ 中使用 [] 运算符获取对象
- 3des - 我可以在 google KMS HSM 中使用 3DES 密钥吗?
- sql - 将 varchar 值 '28,29,30,31,32' 转换为数据类型 smallint 时转换失败
- angular - Angular NgxSpinnerService 无法隐藏
- excel - 当范围达到一定大小时,Excel散点图x轴自动恢复为0
- ios - Swift:通过循环以编程方式在另一个下方添加多个堆栈视图
- python - 如何从带有pynput和winsound的回调函数“继续”for循环?
- microsoft-graph-api - 使用 Graph API 和 Office365 以编程方式创建日历
- msbuild - 如何在 MSBuild 中获取已安装 nuget 的版本?
- python - 在 python 中使用 sys.stdin.read() 输入参数后应该按下什么按钮