본문으로 건너뛰기
cccskills
무료GitHub에 공개

metrics-graphana

Query Prometheus metrics through Grafana and manage dashboards as JSON files. Use it to investigate current values and trends, add or adjust panels, and preview dashboard updates before applying them.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

Query and manage Grafana dashboards and Prometheus metrics for Happy infrastructure. Covers grafanactl CLI usage, direct Prometheus queries through Grafana proxy, and dashboard-as-code workflows. Use when user asks about metrics, dashboards, monitoring, Grafana, Prometheus, or wants to add/modify panels.

설치 방법 보기

이럴 때 유용합니다

  • Investigating error rates and response times
  • Adding panels to a Grafana dashboard
  • Managing dashboard configuration as JSON
  • Checking current metrics and historical trends

포함된 파일(1)

  • SKILL.md7.8 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Metrics & Grafana

You are the observability operator for the Happy infrastructure. You can query live Prometheus metrics, manage Grafana dashboards as code, and investigate production behavior.

Environment Variables

Credentials are stored in the repo root .env file (gitignored). Load them before running commands:

GRAFANA_URL=...
GRAFANA_USER=...
GRAFANA_PASSWORD=...
GRAFANA_PROMETHEUS_UID=...

To load in shell:

set -a; source .env; set +a

All commands below use $GRAFANA_URL, $GRAFANA_USER, $GRAFANA_PASSWORD, and $GRAFANA_PROMETHEUS_UID from the environment.


Prerequisites

Install grafanactl

go install github.com/grafana/grafanactl/cmd/grafanactl@latest

Ensure $HOME/go/bin is on your PATH.

Configure grafanactl

# Load env vars first
set -a; source .env; set +a

# Create a context for the Happy Grafana instance
grafanactl config set contexts.happy.grafana.server "$GRAFANA_URL"
grafanactl config set contexts.happy.grafana.user "$GRAFANA_USER"
grafanactl config set contexts.happy.grafana.password "$GRAFANA_PASSWORD"
grafanactl config set contexts.happy.grafana.org-id 1

# Switch to the context
grafanactl config use-context happy

# Verify
grafanactl config check

Config file lives at ~/Library/Application Support/grafanactl/config.yaml (macOS) or ~/.config/grafanactl/config.yaml (Linux).


grafanactl CLI Reference

List resources

grafanactl resources list                    # List all resource types
grafanactl resources get dashboards          # List all dashboards
grafanactl resources get folders             # List all folders

Pull dashboards (export to disk)

grafanactl resources pull dashboards -p ./resources -o json
grafanactl resources pull dashboards/DASHBOARD_ID -p ./resources -o json

Push dashboards (deploy from disk)

# Push all dashboards from ./resources
grafanactl resources push dashboards -p ./resources

# Push a specific dashboard
grafanactl resources push dashboards/DASHBOARD_ID -p ./resources

# IMPORTANT: Use --omit-manager-fields to keep dashboards editable from the Grafana UI
grafanactl resources push dashboards -p ./resources --omit-manager-fields

# Dry run (no changes)
grafanactl resources push dashboards -p ./resources --dry-run

Workflow: Edit a dashboard

# 1. Pull current state
mkdir -p /tmp/grafana-work
grafanactl resources pull dashboards -p /tmp/grafana-work -o json

# 2. Edit the JSON files (add panels, modify queries, etc.)

# 3. Push back — always use --omit-manager-fields to avoid locking the UI
grafanactl resources push dashboards -p /tmp/grafana-work --omit-manager-fields

Warning: Pushing without --omit-manager-fields marks the dashboard as "provisioned" and locks it from UI edits. Always include this flag unless you explicitly want CLI-only management.


Querying Prometheus Directly

You can query Prometheus through Grafana's datasource proxy API. This is useful for live investigation without touching the Grafana UI.

Instant query (current value)

curl -s -u "$GRAFANA_USER:$GRAFANA_PASSWORD" \
  --data-urlencode 'query=YOUR_PROMQL_HERE' \
  "$GRAFANA_URL/api/datasources/proxy/uid/$GRAFANA_PROMETHEUS_UID/api/v1/query" \
  | python3 -m json.tool

Range query (time series)

curl -s -u "$GRAFANA_USER:$GRAFANA_PASSWORD" \
  --data-urlencode 'query=YOUR_PROMQL_HERE' \
  --data-urlencode 'start=UNIX_TIMESTAMP' \
  --data-urlencode 'end=UNIX_TIMESTAMP' \
  --data-urlencode 'step=60' \
  "$GRAFANA_URL/api/datasources/proxy/uid/$GRAFANA_PROMETHEUS_UID/api/v1/query_range" \
  | python3 -m json.tool

List all metric names

curl -s -u "$GRAFANA_USER:$GRAFANA_PASSWORD" \
  "$GRAFANA_URL/api/datasources/proxy/uid/$GRAFANA_PROMETHEUS_UID/api/v1/label/__name__/values" \
  | python3 -c "import json,sys; [print(n) for n in json.load(sys.stdin)['data']]"

Filter metric names

# Find all RPC-related metrics
curl -s -u "$GRAFANA_USER:$GRAFANA_PASSWORD" \
  "$GRAFANA_URL/api/datasources/proxy/uid/$GRAFANA_PROMETHEUS_UID/api/v1/label/__name__/values" \
  | python3 -c "import json,sys; [print(n) for n in json.load(sys.stdin)['data'] if 'rpc' in n.lower()]"

Key Metrics

Application metrics (handy-server)

MetricTypeDescription
rpc_calls_totalcounterRPC calls by method and result (success, not_available, target_disconnected, timeout)
rpc_call_duration_seconds_buckethistogramRPC call duration by method
rpc_lookup_retries_buckethistogramNumber of retries per socket lookup by method
rpc_fetchsockets_timeouts_totalcounterfetchSockets timeout count by context (lookup, presence)
websocket_connections_totalgaugeActive WebSocket connections by type
websocket_events_totalcounterWebSocket events by type
http_requests_totalcounterHTTP requests by method, route, status
http_request_duration_seconds_buckethistogramHTTP request duration by route
session_cache_operations_totalcounterSession cache hits/misses by operation
session_alive_events_totalcounterSession keepalive events
machine_alive_events_totalcounterMachine keepalive events
database_records_totalgaugeRecord counts by table
database_updates_skipped_totalcounterSkipped DB updates by type

Useful PromQL queries

# RPC success rate by method
sum by(method) (rate(rpc_calls_total{result="success"}[5m]))
/ (sum by(method) (rate(rpc_calls_total[5m])))

# RPC failures by method and reason
sum by (method, result) (rate(rpc_calls_total{result!="success"}[5m]))

# RPC failures by type only
sum by (result) (rate(rpc_calls_total{result!="success"}[5m]))

# RPC P95 latency by method
histogram_quantile(0.95, sum by (method, le) (rate(rpc_call_duration_seconds_bucket[5m])))

# Socket lookup retry distribution (P95)
histogram_quantile(0.95, sum by (method, le) (rate(rpc_lookup_retries_bucket[5m])))

# fetchSockets timeout rate by context
sum by (context) (rate(rpc_fetchsockets_timeouts_total[5m]))

# HTTP error rate
sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m]))

# Top routes by request rate
topk(10, sum by(method, route) (rate(http_requests_total[5m])))

Dashboards

Happy Server Application Metrics

  • ID: 470da978-91f7-4721-be2c-cc451bf074a2
  • Tags: happy-server, application, websocket, http, database
  • Panels: WebSocket connections, session cache, alive events, HTTP metrics, database stats, RPC metrics

Adding a panel

When adding panels to a dashboard JSON, follow this pattern:

  1. Use the Prometheus datasource: {"type": "prometheus", "uid": "$GRAFANA_PROMETHEUS_UID"}
  2. Pick the next available id (check existing panels for max id)
  3. Position with gridPos: h = height (8 standard), w = width (12 half, 24 full), x = column (0 or 12), y = row
  4. Common panel types: stat, timeseries, piechart, bargauge, table
  5. Set appropriate unit: percentunit, ops, s, short, reqps

Tips

  • Always pull before editing to get the latest state
  • Use --dry-run on push to preview changes
  • The --omit-manager-fields flag is essential for hybrid CLI+UI workflows
  • Range queries need Unix timestamps — use date +%s to get current time
  • When investigating metrics, start with instant queries for current state, then use range queries for trends

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Automate real browser tasks to test websites, complete forms, and collect page information. The skill guides agents through identifying clickable elements, interacting with pages, comparing page states, and saving screenshots or PDFs.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Testing form submissions and page navigation
  • Comparing page appearance before and after changes
  • Extracting page text and saving PDFs
slopus/happy2.4만2026년 10월 20일 업데이트

Trace application behavior and explain data structures using compact text tree diagrams. The diagrams connect user actions to real functions, data types, state changes, and the components that render again as a result.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Tracing what happens after a user action
  • Investigating why a component renders again
  • Mapping data structures and their consumers
slopus/happy2.4만2026년 10월 20일 업데이트

dev

무료

Set up and run Happy components locally, including its CLI, server, mobile app, and desktop app. The guide covers building, testing, checking logs, and separating development data using pnpm, the project's package management tool.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Setting up a local Happy development environment
  • Rebuilding the CLI and checking its daemon
  • Running the server and app locally
slopus/happy2.4만2026년 10월 20일 업데이트

maintain

무료

Organize Happy's GitHub issues, find duplicates, and check whether reported bugs are fixed on main, the primary development branch. Prepare replies and proposed actions for maintainer review, with explicit approval required before changes affecting contributors.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Grouping open issues and identifying duplicates
  • Checking whether reported bugs are fixed on main
  • Drafting replies and issue closure comments
slopus/happy2.4만2026년 10월 20일 업데이트

Develop a product or side-project idea through guided questions and premise checks. Startup discussions examine evidence of demand, while builder discussions explore possibilities and scope, producing a design document before implementation begins.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Examining demand for a startup idea
  • Defining the smallest useful internal project
  • Shaping a hackathon or side-project idea
slopus/happy2.4만2026년 10월 20일 업데이트

release

무료

Guide releases of Happy's CLI, mobile app, web app, and server. Choose versions and release channels, follow build and test checks, publish through the designated services, and verify the resulting packages or app updates.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Publishing a stable or beta CLI release
  • Delivering preview or production mobile updates
  • Building native apps and submitting to stores
slopus/happy2.4만2026년 10월 20일 업데이트

slopus의 스킬 모두 보기

이 스킬의 문제 신고