Skip to main content

Grafana

Overview

Grafana digunakan untuk metrics visualization dan dashboard.

Configuration

Docker Compose

grafana:
image: grafana/grafana:latest
container_name: grafana
ports:
- "3001:3000"
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: grafana123
GF_INSTALL_PLUGINS: grafana-clock-panel,grafana-piechart-panel
volumes:
- grafana-data:/var/lib/grafana
- ./configs/grafana/provisioning:/etc/grafana/provisioning
mem_limit: 256m
cpus: "0.25"
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:3000/api/health"]
interval: 30s
timeout: 10s
retries: 3

Access

Web UI

http://localhost:3001

Credentials

UsernamePassword
admingrafana123

Datasources

Prometheus

apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: true

OpenSearch

apiVersion: 1
datasources:
- name: OpenSearch
type: opensearch
access: proxy
url: https://opensearch:9200
jsonData:
esVersion: "8.0.0"
timeField: "@timestamp"
secureJsonData:
username: admin
password: MyStrong@OpenSearch2026!

Dashboards

CLM Dashboard

{
"dashboard": {
"title": "CLM Dashboard",
"panels": [
{
"title": "Pipeline Status",
"type": "stat",
"targets": [
{
"expr": "up{job=~\"backend|fluentd|opensearch\"}",
"legendFormat": "{{job}}"
}
]
},
{
"title": "Request Rate",
"type": "graph",
"targets": [
{
"expr": "rate(http_requests_total[5m])",
"legendFormat": "{{method}} {{status}}"
}
]
},
{
"title": "Error Rate",
"type": "graph",
"targets": [
{
"expr": "rate(http_requests_total{status=~\"5..\"}[5m]) / rate(http_requests_total[5m]) * 100",
"legendFormat": "Error %"
}
]
}
]
}
}

Container Metrics

{
"dashboard": {
"title": "Container Metrics",
"panels": [
{
"title": "CPU Usage",
"type": "graph",
"targets": [
{
"expr": "rate(container_cpu_usage_seconds_total{container!=\"\"}[5m]) * 100",
"legendFormat": "{{name}}"
}
]
},
{
"title": "Memory Usage",
"type": "graph",
"targets": [
{
"expr": "container_memory_usage_bytes{container!=\"\"} / 1024 / 1024",
"legendFormat": "{{name}}"
}
]
}
]
}
}

Provisioning

Datasource Provisioning

# provisioning/datasources/prometheus.yml
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: true

Dashboard Provisioning

# provisioning/dashboards/dashboards.yml
apiVersion: 1
providers:
- name: 'CLM'
orgId: 1
folder: 'CLM'
type: file
disableDeletion: false
editable: true
options:
path: /etc/grafana/provisioning/dashboards

Monitoring

Health Check

curl http://localhost:3000/api/health

API

# List datasources
curl -u admin:grafana123 http://localhost:3000/api/datasources

# List dashboards
curl -u admin:grafana123 http://localhost:3000/api/search

Next Steps