Grafana

From event4u-app/agent-config · View interactive version

Grafana is an AI agent skill from the GitHub repository event4u-app/agent-config. Use when working with Grafana — dashboards, Loki LogQL queries, alerting rules, monitoring panels — even when the user just says 'build me a dashboard' or 'query the logs' without naming Grafana.

How to use this skill

Skill file

Grafana Skill

When to use

Use this skill when:

Procedure: Create Grafana dashboard

  1. Inspect existing Grafana assets — Check the project's Grafana location (Docker config, dashboards/, provisioning) and existing datasources (Loki, Prometheus) before adding panels.
  2. Decide signals and layout — Pick the queries (LogQL / PromQL) and panel types per signal; reuse naming and label conventions below.
  3. Author the dashboard JSON — Add provisioned JSON under the dashboards path; wire datasources and template variables.
  4. Verify — Reload Grafana, confirm panels render against real data, and check alert rules fire on synthetic test inputs.

Project setup

Check if the project has a dedicated Grafana module or Docker config. Typical structure:

{grafana-location}/
├── .docker/
│   ├── grafana/
│   │   ├── dashboards/              ← Dashboard JSON files (provisioned)
│   │   ├── provisioning/
│   │   │   ├── datasources/         ← Loki, Prometheus data sources
│   │   │   └── dashboards/          ← Dashboard provisioning config
│   │   └── alerting/                ← Alert rules, contact points, notification policies
│   └── loki/
│       └── loki-config.yml          ← Loki server configuration
├── App/
│   ├── Logging/                     ← Loki timestamp processors
│   └── Console/Commands/            ← GrafanaPushDashboardsCommand
├── Docs/
│   └── Loki.md                      ← Loki documentation
└── Routes/console.php

Configuration

Dashboard conventions

JSON provisioning

Dashboards are stored as JSON in .docker/grafana/dashboards/ and auto-provisioned.

Use GrafanaPushDashboardsCommand to push dashboards to remote Grafana instances.

Panel rules

labelTypes, traceID, traceID (field) → add to excludeByName in the organize transformation.

name the column "Imported", not "Uploaded".

Naming

| Element | Convention | Example |

|---|---|---|

| Dashboard title | Descriptive, Title Case | "Import Overview (Loki)" |

| Panel title | Short, descriptive | "Import Results by Status" |

| Variable names | lowercase, underscore | $fqdn, $environment |

Loki LogQL

Query patterns

# Filter by service and status
{service="import_result"} |= "DONE" | json | status = "DONE"

# Count by label
sum by (status) (count_over_time({service="import_result"} | json [$__interval]))

# Filter by customer FQDN
{service="import_result", fqdn=~"$fqdn"} | json

Service labels

| Label | Purpose | Notes |

|---|---|---|

| import_result | Final import states (DONE, FAILED) | Use for result dashboards |

| import_snapshot | Cron-based status snapshots | Use for timeline dashboards |

| service=import | Legacy static label | Do NOT query — use specific labels above |

Best practices

Alerting

Structure

.docker/grafana/alerting/
├── alert-rules.yml          ← Alert conditions and thresholds
├── contact-points.yml       ← Notification targets (Slack, email)
└── notification-policies.yml ← Routing rules (which alerts → which contacts)

Conventions

Integration with logging

The project uses structured logging via Monolog → Loki:

When adding new log entries for Grafana visualization:

  1. Use a dedicated log channel (defined in config/logging.php)
  2. Log as JSON with consistent field names
  3. Add appropriate Loki labels for filtering
  4. Update or create a dashboard panel for the new data

Related

Output format

  1. Grafana dashboard JSON or LogQL/PromQL queries
  2. Panel configuration with data source and thresholds
  3. Alert rule definitions where applicable

Gotcha

Do NOT

Auto-trigger keywords

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.