算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
telemetry【设计与创意】Operate the observability stack that deploys as one unit: Prometheus scrape configuration, recording and alerting rules, relabeling, retention, and high availability; OpenTelemetry Collector pipelines (receivers, processors, exporters, sampling, trace/span correlation); and Loki ingest, LogQL, retention, and label design — with a bundled read-only te…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this skill to operate the telemetry stack — Prometheus, the OpenTelemetry Collector, and Loki — as the one deployment unit it ships as: collection and scraping, ingestion, retention, and the rules that turn raw signals into alerts. This is a tool skill for one stack of named tools. Observability strategy — SLIs, SLOs, error budgets, and what to instrument — belongs to platform-engineering; dashboards, panels, and Grafana-side alert rules, contact points, and notification policies belong to grafana. This skill owns the collection/ingest/retention layer and the Prometheus rules files that both of those skills consume.
telemetry-check script runs rule sanity and scrape-target reachability checks without changing anything.promtool rules push, a collector restart, a retention-policy change — require an explicit human directive naming the instance.prometheus.yml, collector pipelines, or credentials into chat.scripts/telemetry-check is an agent-first, read-only checker. It parses Prometheus rules files with a bundled stdlib YAML reader and runs dependency-free structural sanity checks; it extracts static targets from scrape configs and probes TCP reachability; and it emits bounded JSON. It never writes files and never sends data anywhere.
scripts/telemetry-check --help # no server needed
scripts/telemetry-check --rules rules.yml --json # rule sanity, machine-readable
scripts/telemetry-check --scrape prometheus.yml --json # probe static targets
scripts/telemetry-check --targets targets.txt --timeout 5
Exit codes: 0 all checks passed, 1 issues found or a fatal error, 2 usage error. telemetry-check --rules checks structure only: exactly one of record/alert per rule, a non-empty expression with balanced delimiters, valid durations, recording-rule and label names, and string-only label values. Use promtool check rules separately for full PromQL parsing.
telemetry-check --rules and --scrape on the configs, then check the live status endpoints (/-/healthy, /api/v1/targets, collector health, Loki ready) where access exists.references/05-query-workflows.md. Define the signal, selector, UTC time window, step/limit, and expected unit; validate syntax separately from semantics; execute read-only instant then bounded range/log queries; and capture status, scope, time, limits, warnings, and cardinality evidence.scrape_configs): one job per scrape group with a deliberate scrape_interval, scrape_timeout below it, and metrics_path. Prefer static_configs for known endpoints and service discovery (*_sd_configs) for dynamic ones. Verify the running config with /api/v1/status/config and targets with /api/v1/targets?state=active.groups of record or alert rules with a PromQL expr, optional for/keep_firing_for durations, and labels/annotations. Validate every change with promtool check rules for full PromQL parsing and with the bundled telemetry-check --rules for dependency-free structural sanity before reload. Rules must be small, well-named, and reviewable — a 100-line expression is a debugging liability, not a rule.relabel_configs and metric_relabel_configs rewrite labels before ingestion. Use them to enforce label naming, drop high-cardinality or internal labels, and attach scrape metadata. Relabeling mistakes silently change series identity — verify with a targeted curl of /metrics and the target's scrapeUrl in /api/v1/targets.--storage.tsdb.retention.time and --storage.tsdb.retention.size bound local block retention; blocks are 2h by default. Retention is a capacity decision (see references/04-stack-integration-and-retention.md), not a default to leave alone. Watch prometheus_tsdb_head_series and prometheus_tsdb_compaction for cardinality and compaction pressure.--query.max-concurrency headroom and consistent external labels let you shard or deduplicate at the query layer (Thanos, Mimir, or Grafana data sources). Alerting rules must not double-fire: HA pairs need a dedup layer or consistent labeling, and rule evaluation must stay consistent across replicas. Rule evaluation state (for counters) is local to each instance.receivers → processors → exporters per signal type (metrics, logs, traces). Keep pipelines narrow and per-signal; a pipeline that mixes signals becomes un-debuggable. Each pipeline must have at least one exporter; unused receivers/exporters are dead configuration.memory_limiter processor belong before exporters; tail_sampling belongs on trace pipelines only.tail_sampling on traces decides at the batch level; probabilistic_sampler is stateless and cheaper. Sample deliberately: full traces for errors and slow paths, tail sampling for high-volume success traffic, and never sample away the error signal. Sampling must be coordinated with retention — a sampled trace is gone forever, so the decision belongs in the pipeline design, not in an emergency.trace_id and span_id in log lines and metric exemplars so LogQL and PromQL can pivot back to the trace. The collector's spanmetrics processor derives RED metrics from spans, and OTLP logs with trace context land in Loki with trace_id as a structured label for correlation. Trace context propagation is an application-level concern that backend-engineering owns; the collector side is here./loki/api/v1/push) from Promtail, the OTel Collector's loki exporter, or the Grafana Agent/Alloy. Verify ingest with loki_distributor_bytes_received_total and the ready endpoint; an ingest that silently drops (rate limits, too many outstanding requests) hides outages.{label="value"} |= "filter" | json selects streams and filters lines; label matchers are the primary cost driver. LogQL analytics (sum by (...) (rate({app="x"} |~ "error"[5m]))) work on the label index plus line filtering — design labels so the matchers you actually use are cheap.retention_period and retention_size apply per tenant; the compactor enforces them and merges index shards. Log volume is unbounded if ungoverned — set retention before rollout, track it with loki_compactor metrics, and treat log retention as a compliance decision with an owner.| json/| regexp or OTel structured metadata. Cardinality guidance: a label whose values change with every log line does not belong in the index.Retention is a stack-wide decision: Prometheus blocks (raw samples), OTel Collector buffering (in-memory queue, exporter retries), and Loki (indexed logs) each have independent retention, and the combined storage footprint is what the team pays for. Decide per component based on the question the data answers (hot metrics for alerting, samples for trends, logs for debugging and audit), set it in config, and review it on a schedule. See references/04-stack-integration-and-retention.md for the trade-off tables and the alerting rule that watches retention.
| Load when | Reference |
|---|---|
| Sources, version observations, refresh procedure | references/00-source-index.md |
| Scrape config, recording/alerting rules, relabeling, retention, HA | references/01-prometheus-operations.md |
| Collector pipelines, receivers/processors/exporters, sampling, correlation | references/02-opentelemetry-collector.md |
| Ingest, LogQL, retention, label design | references/03-loki-operations.md |
| PromQL/LogQL construction, semantic review, bounded cost, and no-data diagnosis | references/05-query-workflows.md |
| Cross-component retention decisions and stack integration | references/04-stack-integration-and-retention.md |
scripts/telemetry-check: read-only rule sanity + scrape-target reachability checker (stdlib-only, --json, --rules/--scrape/--targets, --help without a server).tests/test_telemetry_check.py: deterministic tests against fixture configs, including the read-only contract.fixtures/: prometheus-rules.yml (valid rules) and scrape-config.yml (valid scrape config) used by the tests and as starting points.references/: five dated, source-indexed references plus the source index, including the bounded PromQL/LogQL workflow.evals/evals.json: six output-quality evaluation cases for agent runs.| Claim | Minimum evidence |
|---|---|
| A rules file is structurally sound | telemetry-check --rules FILE --json exits 0 with no errors |
| A rules file is semantically valid | promtool check rules FILE exits 0 |
| A target is scrapable | telemetry-check --scrape CONFIG --json reports it reachable, and /api/v1/targets shows state="up" |
| A pipeline is live | Collector health endpoint responds and per-signal metrics (otelcol_receiver_*, otelcol_exporter_*) advance |
| Ingest is healthy | Distributor metrics advance and the ready endpoint returns 200 |
| Retention is governed | retention_period/retention_size are set explicitly, and compactor/TSDB metrics confirm the policy |
telemetry-check as anything but what it is — read-only. It has no mutation surface.