Back to home@LJH-snow

dsh-tool-monitoring

Prometheus and Alertmanager tool plugin for DeepSeek Harness

Stars
0
Language
TypeScript
Created
Aug 28, 2026
Updated
Aug 28, 2026

Introduction

dsh-tool-monitoring

English | 中文

A Cordis tool plugin that gives DeepSeek Harness (dsh) monitoring and alerting capabilities. Agents can query Prometheus, inspect targets, alerts, rules, series, labels and TSDB status, and manage Alertmanager alerts, alert groups, silences and receivers.

It follows the official plugin architecture with ctx.tools.register(defineTool(...)) and the adding-a-tool contract.

Install

Install from npm:

npm install @libai168/dsh-tool-monitoring

Or install directly from GitHub:

npm install github:LJH-snow/dsh-tool-monitoring

Requires @deepseek-ai/cordis (^4.0.1) and @deepseek-ai/dsh-tools (^0.1.0-rc.6) as peer dependencies, provided by the host dsh runtime.

Configuration

Load the plugin in a dsh composition config (cordis.yml):

- name: 'github:LJH-snow/dsh-tool-monitoring'
  config:
    prometheusBaseUrl: 'http://prometheus:9090'       # optional, default http://localhost:9090
    prometheusToken: 'plain_token_or_Bearer_token'    # optional
    alertmanagerBaseUrl: 'http://alertmanager:9093'   # optional, default http://localhost:9093
    alertmanagerToken: 'plain_token_or_Bearer_token'  # optional
    timeoutMs: 15000                                  # optional, default 15000
    allowWrite: false                                 # optional, write tools are disabled by default

Full example: examples/cordis.yml.

Each component can also use HTTP Basic Auth with prometheusUsername/prometheusPassword or alertmanagerUsername/alertmanagerPassword. Set a base URL to an empty string to disable that component and return an explicit connected: false business value.

Security: write tools are gated by allowWrite. Keep it false unless the dsh runtime is explicitly allowed to delete Prometheus series, create or delete Alertmanager silences, or send alerts.

Tools

Prometheus tools:

ToolDescriptionWrite
prometheus_queryRun a PromQL instant queryno
prometheus_query_rangeEvaluate a PromQL expression over a time rangeno
prometheus_list_targetsList scrape targets with health and last errorno
prometheus_list_alertsList active alerts with labels, annotations, state and valuesno
prometheus_list_rulesList recording and alerting rulesno
prometheus_list_seriesFind series label sets matching a PromQL selectorno
prometheus_list_labelsList label namesno
prometheus_get_label_valuesList values for one labelno
prometheus_get_tsdb_statusRead TSDB cardinality and head block statisticsno
prometheus_delete_seriesDelete series matching PromQL selectorsyes

Alertmanager tools:

ToolDescriptionWrite
alertmanager_get_statusGet version, uptime and status payloadno
alertmanager_list_alertsList alerts with filters and receiverno
alertmanager_list_alert_groupsList alert groups by receiverno
alertmanager_list_silencesList silences with matchers and scheduleno
alertmanager_list_receiversList receiver namesno
alertmanager_create_silenceCreate a silence with JSON matchersyes
alertmanager_delete_silenceDelete a silence by IDyes
alertmanager_send_alertsSend an alert batch as JSONyes

Behavior Contract

  • If a component base URL is not configured, read tools return { connected: false, reason }.
  • Write tools return { ok: false, reason } when allowWrite is disabled or when the monitoring service rejects the request with a validation error.
  • Prometheus API-level errors and HTTP 400 write validation errors are mapped to business failure values.
  • Infrastructure errors such as invalid credentials (401), forbidden access (403), rate limiting (429), or server failures (5xx) throw MonitoringError.
  • Every request forwards exec.signal and uses a configurable timeout (default 15 seconds).

Development

npm install
npm run typecheck
npm test
npm run build

See DEVELOPMENT.md for architecture and coverage.

License

MIT