UI 로도 추가할 수 있지만, 재설치와 이관을 생각하면 프로비저닝 파일로 관리하는 편이 낫다.
/etc/grafana/provisioning/datasources/ 아래에 YAML 을 둔다. Grafana 가 기동할 때 읽는다.
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
jsonData:
timeInterval: 15s
httpMethod: POST
- name: Loki
type: loki
access: proxy
url: http://loki:3100
- name: OpenSearch
type: grafana-opensearch-datasource
access: proxy
url: https://opensearch:9200
basicAuth: true
basicAuthUser: grafana
jsonData:
timeField: '@timestamp'
flavor: opensearch
secureJsonData:
basicAuthPassword: '<비밀번호>'
| 값 | 동작 |
|---|---|
proxy |
Grafana 서버가 대신 질의한다. 데이터 소스가 사설망에 있어도 된다 |
direct |
브라우저가 직접 붙는다. CORS 와 방화벽을 열어야 한다 |
특별한 이유가 없으면 proxy 를 쓴다.
secureJsonData 에 넣은 값은 Grafana DB 에 암호화돼 저장되고 API 로 다시 읽히지 않는다. 평문 jsonData 에 비밀번호를 넣지 않는다.
프로비저닝으로 만든 데이터 소스는 UI 에서 지워지지 않는다. 파일에서 지우려면 deleteDatasources 를 쓴다.
apiVersion: 1
deleteDatasources:
- name: OldPrometheus
orgId: 1
sudo systemctl restart grafana-server