aiagent/skill/embedded/builtin/query-datasource/SKILL.md
Query monitoring metrics, logs, and time-series data from various datasources on the Nightingale monitoring platform.
Based on the datasource type the user needs, read the corresponding file under the datasources/ directory to get the query method and parameter format:
The user needs to provide:
http://<n9e-host>:<port><username>/<password>If the user has not provided the above information, use the AskUserQuestion tool to ask.
POST /api/n9e/auth/login
Content-Type: application/json
Body: {"username":"<username>","password":"<password>"}
Extract dat.access_token from the response, and include Authorization: Bearer <token> in all subsequent requests.
Retrieve the datasource list to determine the datasource ID and type to query:
POST /api/n9e/datasource/list
Authorization: Bearer <token>
Content-Type: application/json
Body: {}
Each datasource in the response contains id, name, and plugin_type.
If the user has not specified a datasource, use the AskUserQuestion tool to display the available datasources and let the user choose.
Based on the datasource's plugin_type, read the corresponding datasources/*.md file to get the query API and parameter format.
Present the query result to the user as a readable Markdown table or list.
| plugin_type | Datasource | Query Language | Use Case | Reference File |
|---|---|---|---|---|
prometheus | Prometheus / VictoriaMetrics | PromQL | Metric/time-series query | prometheus.md |
elasticsearch | Elasticsearch | ES DSL / Lucene | Log query | elasticsearch.md |
opensearch | OpenSearch | ES DSL / Lucene | Log query | opensearch.md |
loki | Loki | LogQL | Log query | loki.md |
ck | ClickHouse | SQL | Metric/log query | clickhouse.md |
mysql | MySQL | SQL | Metric query | mysql.md |
pgsql | PostgreSQL | SQL | Metric query | pgsql.md |
tdengine | TDengine | SQL | Time-series query | tdengine.md |
doris | Doris | SQL | Log query | doris.md |
victorialogs | VictoriaLogs | LogsQL | Log query | victorialogs.md |
All datasources can access their native APIs through the generic proxy:
<ANY_METHOD> /api/n9e/proxy/<datasource_id>/<native API path>
Authorization: Bearer <token>
For example:
/api/n9e/proxy/1/api/v1/query?query=up/api/n9e/proxy/2/_cat/health/api/n9e/proxy/3/loki/api/v1/labelsAll datasources (except Prometheus) can use the unified time-series query endpoint:
POST /api/n9e/ds-query
Authorization: Bearer <token>
Content-Type: application/json
{
"cate": "<plugin_type>",
"datasource_id": 1,
"query": [<query object>]
}
Generic log query endpoint:
POST /api/n9e/logs-query
Authorization: Bearer <token>
Content-Type: application/json
{
"cate": "<plugin_type>",
"datasource_id": 1,
"query": [<query object>]
}
The exact structure of the query object varies by datasource type; see each datasource file for details.
ClickHouse, MySQL, PostgreSQL, and Doris share the following metadata query endpoints:
POST /api/n9e/db-databases // List databases
POST /api/n9e/db-tables // List tables
POST /api/n9e/db-desc-table // View table structure
TDengine uses dedicated endpoints:
POST /api/n9e/tdengine-databases
POST /api/n9e/tdengine-tables
POST /api/n9e/tdengine-columns
datasource_id; obtain it first via POST /api/n9e/datasource/list$from and $to to represent the time range; the system replaces them automaticallyvalueKey (numeric column) and labelKey (grouping column); separate multiple columns with spaces{"dat": <data>} structure