query-datasource

Query metrics and logs from Nightingale datasources via PromQL, SQL, LogQL, and Elasticsearch DSL.

13.3k|1.8k|Updated Mar 3, 2020
One-click install
npx skills add https://github.com/ccfos/nightingale --skill query-datasource
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query-datasource
Source: https://github.com/ccfos/nightingale/tree/main/aiagent/skill/embedded/builtin/query-datasource
Command: npx skills add https://github.com/ccfos/nightingale --skill query-datasource

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Monitoring data is scattered across many backends like Prometheus, Elasticsearch, Loki, ClickHouse, and MySQL, each with its own query language and API. This Skill provides a unified workflow to authenticate against a Nightingale (n9e) server, discover configured datasources, and run the correct query for each datasource type without memorizing every API.

Core Features & Use Cases

  • Multi-datasource querying: Supports Prometheus/VictoriaMetrics (PromQL), Elasticsearch/OpenSearch (ES DSL/Lucene), Loki (LogQL), VictoriaLogs (LogsQL), and SQL databases including ClickHouse, MySQL, PostgreSQL, TDengine, and Doris.
  • Guided API workflow: Walks through login to obtain a token, listing datasources to get IDs, then executing instant, range, time-series, or log queries through n9e proxy and unified query endpoints.
  • Metadata discovery: Lists databases, tables, columns, indices, labels, and fields so queries can be built against real schemas.
  • Use Case: Ask to "query CPU usage of host web-01 over the last hour" and the Skill logs into n9e, finds the Prometheus datasource, runs the PromQL range query, and returns a formatted table of values.

Quick Start

Ask the assistant to query CPU usage over the last hour from your Nightingale server, providing the n9e address and your username and password.

Frequently Asked Questions about query-datasource

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I query Prometheus metrics through the Nightingale API?

Log in via POST /api/n9e/auth/login to get a token, then call POST /api/n9e/query-range-batch with the datasource_id, PromQL expression, start, end, and step. You can also proxy native Prometheus endpoints like /api/v1/query through /api/n9e/proxy/<datasource_id>/.

How do I search logs in Elasticsearch or Loki from Nightingale?

For Elasticsearch, send an NDJSON _msearch request through /api/n9e/proxy/<datasource_id>/_msearch with a Lucene query_string and time range filter. For Loki, call /loki/api/v1/query_range through the proxy with a LogQL expression and nanosecond timestamps.

Which datasource types does Nightingale support for queries?

Supported types include Prometheus/VictoriaMetrics, Elasticsearch, OpenSearch, Loki, VictoriaLogs, ClickHouse, MySQL, PostgreSQL, TDengine, and Doris. Each type uses its native query language such as PromQL, LogQL, LogsQL, ES DSL, or SQL.

Can I run INSERT or UPDATE statements on SQL datasources in Nightingale?

No. SQL-type datasources such as ClickHouse, MySQL, PostgreSQL, and Doris are read-only through the n9e query endpoints. Write operations like CREATE, INSERT, UPDATE, DELETE, ALTER, and DROP are prohibited.

How do time range variables work in Nightingale SQL queries?

Use $from and $to placeholders in your SQL, and the system replaces them with Unix timestamps in seconds. Depending on the database, wrap them with functions like FROM_UNIXTIME() in MySQL or to_timestamp() in PostgreSQL.

Why does my Nightingale time-series query return no data?

Common causes are a missing or wrong datasource_id, omitting the required keys.valueKey mapping to a numeric column, or an incorrect time range. First verify the datasource via POST /api/n9e/datasource/list and confirm the query columns exist.