app icon
Prometheus Query
0.0.2

Query Prometheus metrics using PromQL with time range support

lework/prometheus2815 installs

prometheus

Author: lework
Version: 0.0.2
Type: tool

Description

Creating a Dify Plugin

dify plugin init

Packaging the Plugin

dify plugin package ./prometheus

Prometheus Query Plugin

A Prometheus query plugin for Dify that allows users to query Prometheus metric data using PromQL.

Features

  • Query Prometheus metric data using PromQL
  • Support for time range queries (relative and absolute time)
  • Support for basic authentication and token authentication
  • Automatic formatting of results for easy understanding
  • Support for Markdown table output, clearly displaying the latest value of each metric with labels as columns
  • Kubernetes Pod resource metrics query, getting CPU, memory usage and restart count for Pods

Configuration

Before using this plugin, you need to configure the following information:

  • API URL: The URL of the Prometheus server, e.g.,
  • Username/Password: (Optional) Username and password for basic authentication
  • Token: (Optional) Bearer token for authentication

Tools

1. Prometheus Query

Parameters

  • PromQL Query Statement: Required, the PromQL query statement to execute
  • Start Time: Optional, the start time of the query, supports the following formats:
    • RFC3339/ISO8601 format:
    • Relative time: , , , , , etc.
    • Default value: (1 hour ago)
  • End Time: Optional, the end time of the query, supports the same formats as the start time
    • Default value: (current time)
  • Step: Optional, the resolution step of the query
    • Format: , , , etc.
    • Default value: (15 seconds)

Examples

Query CPU Usage
Query Memory Usage

2. Kubernetes Pod Resource Metrics Query

Get resource usage information for Kubernetes Pods, including CPU, memory usage and restart count, displayed in Markdown table format.

Parameters

  • Namespace: Optional, Kubernetes namespace name, if not specified, queries all namespaces
  • Label Selector: Optional, label selector to filter Pods, e.g.,
  • Pod Name Pattern: Optional, regular expression to filter Pod names, e.g.,

Examples

Query Pod Resource Usage in a Specific Namespace
Query Pod Resource Usage for a Specific Application
Query Pod Resource Usage with a Specific Prefix

Return Result

Returns a Markdown table containing the following information:

Pod NameAgeNamespaceNodeReadyPhaseCPU Usage %Memory Usage MiBCPU RequestCPU LimitMemory Request MiBMemory Limit MiBRestarts in 24h
pod-11.0 daydefaultnode1Running0.819%500 MiB0.1001500 MiB2 GiB0
pod-21.7 daysdefaultnode2Running0.380%256 MiB0.1001256 MiB2 GiB0

Return Results

Markdown Table Format (New Feature)

For matrix type query results, the plugin will generate a Markdown table, using labels as table columns, making it easier to clearly display the data:

JSON Format

When a Markdown table cannot be generated, the plugin will return the complete result in JSON format:

CATEGORY
Tool
VERSION
0.0.2
lework·07/01/2025 02:54 PM
REQUIREMENTS
LLM invocation
App invocation
Maximum memory
256MB
Maximum storage
1MB