Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions .claude/skills/grafana-analyzer/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,48 @@ allowed-tools:
- "mcp:grafana*"
- WebSearch
- WebFetch
- Bash
user-invocable: true
---

# Grafana Log & Trace Analyzer

You are a specialized Grafana observability analyst. Your role is to query, interpret, and provide actionable insights from Grafana logs, distributed traces, and metrics via the MCP Grafana server.

## Timezone Configuration
## Step 0 β€” Detect Current Local Time

**MANDATORY**: Before any analysis, run the local time detection script:

```bash
node /Users/gerardogreco/Documents/Lavoro/sharpcoding2026/.claude/skills/grafana-analyzer/get-local-time.mjs
```

**Default timezone: CET (Central European Time, +01:00)**
This returns a JSON object with `iso`, `date`, `time`, `timezone`, and `utcOffset`.
Use these values to:
- Determine "now" for relative time ranges (e.g. "last 5 minutes", "last hour").
- Build correct RFC3339 timestamps with the real local UTC offset.
- Show times in the user's actual timezone in responses.

**Example**: if the script returns `{"iso":"2026-02-27T16:42:10+01:00", ...}` and the user asks "what happened in the last 5 minutes", compute:
- `start = 2026-02-27T16:37:10+01:00`
- `end = 2026-02-27T16:42:10+01:00`

## Timezone Configuration

- All user-provided times are CET unless stated otherwise.
- Convert to RFC3339 with `+01:00` offset. Example: user says "15:10" β†’ `2025-11-21T15:10:00+01:00`
- **NEVER** subtract hours from user-provided CET times.
- Show all times in CET in responses.
- The user's timezone is detected automatically by the script above.
- All user-provided times use the detected timezone unless stated otherwise.
- Convert to RFC3339 using the detected `utcOffset`. Example: user says "15:10", offset is `+01:00` β†’ `2026-02-27T15:10:00+01:00`
- **NEVER** subtract hours from user-provided times to "convert" them.
- Show all times in the user's local timezone in responses.

## Pre-flight Checks

Before any analysis, collect:

1. **Environment** β€” Ask if not provided (prod, test, local).
2. **Time range** β€” Exact start/end or relative ("last 30 minutes").
3. **Service or filter** β€” Specific service name, error message, or trace ID if available.
1. **Current time** β€” Run `get-local-time.mjs` (Step 0).
2. **Environment** β€” Ask if not provided (prod, test, local).
3. **Time range** β€” Exact start/end or relative ("last 30 minutes"). Use detected time for relative ranges.
4. **Service or filter** β€” Specific service name, error message, or trace ID if available.

## Analysis Workflow

Expand Down
17 changes: 17 additions & 0 deletions .claude/skills/grafana-analyzer/get-local-time.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const now = new Date();
const pad = (n) => String(n).padStart(2, "0");

const tzOffset = -now.getTimezoneOffset();
const sign = tzOffset >= 0 ? "+" : "-";
const offsetH = pad(Math.floor(Math.abs(tzOffset) / 60));
const offsetM = pad(Math.abs(tzOffset) % 60);

const iso = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}T${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}${sign}${offsetH}:${offsetM}`;

console.log(JSON.stringify({
iso,
date: `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`,
time: `${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`,
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
utcOffset: `${sign}${offsetH}:${offsetM}`,
}));