When to Use
- •Monitoring stack operations
- •Prometheus queries
- •Grafana dashboard management
- •Alert rule configuration
Prerequisites
- •kubectl access to cluster
- •Prometheus/Grafana deployed
- •Appropriate RBAC permissions
Commands
Prometheus Operations
bash
# Check Prometheus status kubectl get pods -n monitoring -l app.kubernetes.io/name=prometheus # Port forward Prometheus kubectl port-forward -n monitoring svc/prometheus 9090:9090 # Query Prometheus API curl -s http://localhost:9090/api/v1/query?query=up | jq '.data.result' # Check targets curl -s http://localhost:9090/api/v1/targets | jq '.data.activeTargets | length'
Grafana Operations
bash
# Check Grafana status kubectl get pods -n monitoring -l app.kubernetes.io/name=grafana # Port forward Grafana kubectl port-forward -n monitoring svc/grafana 3000:3000 # List data sources curl -s -u admin:admin http://localhost:3000/api/datasources | jq '.[].name'
Alert Management
bash
# Check alertmanager kubectl get pods -n monitoring -l app.kubernetes.io/name=alertmanager # List active alerts curl -s http://localhost:9093/api/v2/alerts | jq '.[].labels.alertname' # Validate Prometheus rules promtool check rules prometheus-rules.yaml
Best Practices
- •Use ServiceMonitors for scrape configuration
- •Set appropriate retention periods
- •Configure alert routing correctly
- •Use recording rules for expensive queries
- •Enable persistent storage for Prometheus
Output Format
- •Command executed
- •Monitoring status summary
- •Active alerts if any
- •Recommendations
Integration with Agents
Used by: @observability, @sre