by lework · v0.0.2
Query Prometheus metrics using PromQL with time range support
This community listing does not yet include every recommended support, privacy, pricing, and permission disclosure. Review the available package permissions before installing.
Available inside your emploidai workspace after installation.
Available inside your emploidai workspace after installation.
Author: lework Version: 0.0.2 Type: tool
dify plugin init
dify plugin package ./prometheus
A Prometheus query plugin for Dify that allows users to query Prometheus metric data using PromQL.
Before using this plugin, you need to configure the following information:
http://localhost:90902023-01-01T00:00:00Z1h, 2d, 3w, 4m, 5y, etc.1h (1 hour ago)now (current time)15s, 1m, 1h, etc.15s (15 seconds)query: 100 - (avg by (instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)
start_time: 1h
end_time: now
step: 1m
query: 100 * (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes))
start_time: 12h
end_time: now
step: 5m
Get resource usage information for Kubernetes Pods, including CPU, memory usage and restart count, displayed in Markdown table format.
app=myapp,component=databasefrontend-.*namespace: default
selector: app=myapp
pod_name_pattern: frontend-.*
Returns a Markdown table containing the following information:
| Pod Name | Age | Namespace | Node | Ready | Phase | CPU Usage % | Memory Usage MiB | CPU Request | CPU Limit | Memory Request MiB | Memory Limit MiB | Restarts in 24h |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| pod-1 | 1.0 day | default | node1 | ✓ | Running | 0.819% | 500 MiB | 0.100 | 1 | 500 MiB | 2 GiB | 0 |
| pod-2 | 1.7 days | default | node2 | ✓ | Running | 0.380% | 256 MiB | 0.100 | 1 | 256 MiB | 2 GiB | 0 |
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:
### node_cpu_seconds_total
| timestamp | instance | job | mode | value |
| :------------------ | :------------- | :--------- | :----- | ----: |
| 2023-03-11T18:15:00 | 10.131.242.148 | prometheus | idle | 0.278 |
| 2023-03-11T18:15:00 | 10.131.242.149 | prometheus | system | 0.156 |
_Showing the most recent data points_
When a Markdown table cannot be generated, the plugin will return the complete result in JSON format:
{
"success": true,
"result_type": "matrix",
"data": [
{
"metric": "metric_name",
"labels": {
"instance": "localhost:9090",
"job": "prometheus"
},
"values": [
{
"timestamp": "2023-01-01T00:00:00.000000",
"value": 12.34
},
...
]
},
...
]
}