The PromQL Copilot is an intelligent assistant integrated into Grafana that converts natural language into Prometheus Query Language (PromQL) statements. It helps you query Prometheus data and configure alerts without learning PromQL syntax.
The PromQL Copilot is now available in all shared Grafana workspaces. If you have not activated Managed Service for Grafana, you can try our logon-free demo.
Product experience:
If you are interested in PromQL for application performance monitoring (APM) metrics, click Logon-free Grafana portal for APM data sources.
If you are interested in PromQL for container metrics, click Logon-free Grafana portal for container data sources.
Features of the PromQL Copilot
Convert natural language to PromQL
Describe the Prometheus data that you want to query in natural language. The PromQL Copilot retrieves relevant metric names, Prometheus operators, and PromQL statements, and provides descriptions.
Automatically generate PromQL comments
The PromQL Copilot can generate explanations for PromQL statements and add them as comments.
How to use the PromQL tool
-
Log on to the Managed Service for Grafana console. In the left-side navigation pane, click Workspace Management.
Log on to a shared Grafana dashboard. In the navigation pane on the left, click the
icon. Then, click the bot icon in the lower-right corner.In the dialog box that appears, enter a natural language description of the PromQL query that you need. For example, you can enter "Write a PromQL query to find the 10 applications with the longest average response time". For more examples of natural language queries, see PromQL scenarios and sample questions.
ImportantMake sure that your question includes the keyword "PromQL".
Click Send. After a few seconds, the PromQL Copilot provides the required PromQL query.
NoteIf you are not satisfied with the answer from the PromQL Copilot, you can click Click here to submit Text2PromQL feedback.
After you obtain the PromQL query, paste it into the Explore page of Managed Service for Grafana. Confirm that the data source for the current dashboard contains the desired metrics.
Then, you can use the custom PromQL query to configure an alert in Managed Service for Prometheus when you create an alert rule. For more information, see Create a Prometheus alert rule using a custom PromQL query.
Demo video
The following video demonstrates how to use the PromQL tool.
Supported Q&A scenarios for Text2PromQL
Text2PromQL supports more than 20 common scenarios for generating PromQL queries. For more information, see the PromQL scenarios and sample questions section below. You can click PromQL Copilot to view the supported scenarios and sample questions.
A list of supported scenarios for generating PromQL queries is returned.
PromQL scenarios and query examples
The following tables list common metrics for Container Service and ARMS, along with their corresponding PromQL queries.
Container Service
Use this feature with the Grafana dashboard for a Prometheus instance for Container Service. For more information, see Prometheus instance for Container Service.
Scenario | Example of an overwrite issue (involving PromQL) |
Node-level resources | Q: Write a PromQL query to view the CPU usage of each Kubernetes node. Q: I want to view the memory usage of the Kubernetes node "172.16.xx.xx:9100". Write a PromQL query for me. Q: I want to configure an alert that triggers if any node in the current cluster is in an abnormal state. How do I write the PromQL query? Q: Write a PromQL query for me to view all nodes that are currently in an abnormal state. |
Pod-level resources | Q: I want to configure an alert that triggers if a pod restarts more than twice within 5 minutes. How do I write the PromQL query? Q: Write a PromQL query to view the pod availability for Pod availability. Q: Write a PromQL query to find the pod with the most anomalies in my Kubernetes cluster. Q: I want to see which jobs have failed. How do I write the PromQL query? |
Container-level resources | Q: Write a PromQL query to view the container with the highest CPU usage in the "default" namespace. Q: Write a PromQL query to view the memory usage of each container where Q: Write a PromQL query to view the 5 containers with the highest memory usage. |
Lingjun dashboard metrics | Q: Write a PromQL query to view the GPU usage of each node on the Lingjun dashboard. Q: Write a PromQL query to view the GPU usage of each cluster on the Lingjun dashboard. |
ARMS application performance monitoring
Use this feature with the default application performance monitoring Grafana dashboard generated by ARMS.
Scenario | Sample questions (must include the keyword "PromQL") |
Average response time | Q: Write a PromQL query to view the average response time for each API. Q: Write a PromQL query to view the RT for each API in application A. Q: Write a PromQL query to find the 10 APIs with the highest response time in application A. Q: Write a PromQL query to find the top 10 apps with the longest response times. |
Error rate | Q: Write a PromQL query to view the error rate for each API in application A over the last minute. Q: In ARMS, write a PromQL query to find the 10 applications with the highest error rates. Q: Write a PromQL query to find the 10 APIs with the highest error rates in application A. Q: Write an ARMS PromQL query to find the 5 APIs with the highest error rates on machine 195.128.xx.xx for application A over the last 2 hours. |
Number of calls | Q: Write a PromQL query to view the QPS of calls to Redis. Q: Write a PromQL query to view the QPS of calls to Dubbo. Q: Write a PromQL query to view the QPS for each API in application A. Q: Write a PromQL query to view the number of calls for each application in the last hour, grouped by machine. Q: Write an ARMS PromQL query to view the number of calls for each API in application A over the last 5 minutes. Q: Write a PromQL query to view the number of calls to the "payment/coupon" API of application A in the last 5 minutes. Q: Write a PromQL query to view the top 10 APIs by number of calls. Q: Write a PromQL query to view the 5 APIs with the highest number of calls in application A. |
Number of errors | Q: Write a PromQL query to view the number of errors for each API in the last 5 minutes. Q: Write a PromQL query to view the total number of HTTP call errors on machine 10.26.xx.xx in the last 5 minutes. Q: Write a PromQL query to find the API with the most errors in the last hour. Q: Write a PromQL query to view the total number of call errors on machine 10.26.xx.xx, where the Clothservice service is deployed, in the last 10 minutes. |
Slow SQL statements | Q: Write a PromQL query to view slow SQL calls that occurred in the last 10 minutes. Q: Write a PromQL query to find the API in application A that made the most slow SQL calls in the last 10 minutes. Q: Write a PromQL query to find the 10 APIs in application A that made the most slow SQL calls. Q: Write a PromQL query to list the specific slow SQL calls that occurred in the last hour. |
Database | Q: Write a PromQL query to find the APIs that failed to call Redis in the last minute. Q: Write a PromQL query to find the 5 APIs that failed to call MySQL most frequently in the last minute. |
HTTP status code | Q: Write a PromQL query to count the number of 4xx or 5xx errors. Q: Write a PromQL query to count the number of 400 and 500 errors. Q: Write a PromQL query to view the number of 4xx requests for application A. |
Number of JVM GC events | Q: Write a PromQL query to see how many full GCs occurred in the last day. Q: Write a PromQL query to see how many full GCs occurred on each host in the last hour. Q: Write a PromQL query to find the hosts for application A that have previously experienced a full GC. Q: Write a PromQL query to find machines that have had more than 5 full GCs. |
JVM GC duration | Q: Write a PromQL query to view the full GC duration on each machine. Q: Write a PromQL query to find the 5 machines with the longest full GC duration. Q: Write a PromQL query to find services with a full GC duration exceeding 1 second. |
QPS increase | Q: Write a PromQL query to view all applications whose traffic has increased in the last 10 minutes. Q: Write a PromQL query to find the application with the largest traffic increase in the last day. Q: Write a PromQL query to find the API in application A with the fastest-growing traffic over the last week. |
Increase in a specific metric | Q: Write a PromQL query to monitor the Q: Write a PromQL query to monitor the increase in the |
ARMS console: Cumulative errors | Q: Write a PromQL query to see if the cumulative number of errors has increased or decreased compared to yesterday. |
ARMS console: Cumulative requests | Q: Write a PromQL query to see how much the cumulative number of requests has changed compared to the last hour. |
ARMS console: Cumulative anomalies | Q: Write a PromQL query to see if the cumulative number of anomalies has increased or decreased compared to yesterday. |
ARMS console: Average duration | Q: Write a PromQL query to see if the average application duration has increased or decreased compared to the previous hour. Q: Write a PromQL query to see the change in average duration compared to yesterday. |
ARMS console: Full GC | Q: Write a PromQL query to see which applications are affected by full GC. Q: Write a PromQL query to see which APIs are affected by full GC. |
ARMS console: Slow calls | Q: Write a PromQL query to see which applications are involved in slow SQL statements. Q: Write a PromQL query to see which APIs have made slow SQL calls. |
New anomalies or errors | Q: Write a PromQL query to view applications with an increasing number of errors. Q: Write a PromQL query to see which machines have an increasing number of errors. Q: Write a PromQL query to view the APIs in application A with an increasing number of errors. |
CPU usage | Q: Write a PromQL query to view the CPU usage of each machine. Q: Write a PromQL query to find the 5 machines with the highest CPU usage in the last 5 minutes. Q: Write a PromQL query to find machines for application A with CPU usage exceeding 70% in the last 5 minutes. Q: Write a PromQL query to find the 5 machines with the fastest-growing CPU usage in the last 5 minutes and list their CPU usage. |