PromCopilot: Simplifying Prometheus Metric Querying in Cloud Native Online Service Systems via Large Language Models

Chenxi Zhang, Bicheng Zhang, Dingyu Yang, Xin Peng, Miao Chen, S. Xie, Gang Chen, Wei Bi, Wei Liu · DOI

Abstract

With the increasing complexity of modern online service systems, understanding the state and behavior of the systems is essential for ensuring their reliability and stability. Therefore, metric monitoring systems are widely used and become an important infrastructure in online service systems. Engineers usually interact with metrics data by manually writing domain-specific language (DSL) queries to achieve various analysis objectives. However, writing these queries can be challenging and time-consuming, as it requires engineers to have high programming skills and understand the context of the system. In this paper, we focus on PromQL, which is the metric query DSL provided by the widely used metric monitoring system Prometheus. We aim to simplify metrics querying by enabling engineers to interact with metrics data in Prometheus through natural language, and we call this task text-to-PromQL. Building upon the insight, this paper proposes PromCopilot, a Large Language Model-based text-to-PromQL framework. PromCopilot first uses a knowledge graph to describe the complex context of a cloud native online service system. Then, through the synergistic reasoning of LLMs and the knowledge graph, PromCopilot transforms engineers’ natural language questions into PromQL queries. To evaluate PromCopilot, we manually construct the first text-to-PromQL benchmark dataset which contains 280 metric query questions. The experiment results show that PromCopilot is effective in text-to-PromQL. When using GPT-4 as the backbone LLM, PromCopilot achieves an accuracy of 69.1% in translating natural language questions to PromQL queries. To the best of our knowledge, this paper is the first study of text-to-PromQL, and PromCopilot pioneered the DSL generation framework for metric querying and analysis.

Introduction

Modern online services rely heavily on metric monitoring systems like Prometheus to track health, performance, and resource usage. To extract insights from these systems, engineers must write queries in domain-specific languages (DSLs) like PromQL. However, writing PromQL is notoriously difficult. It is not just about knowing the syntax; engineers must also possess deep, real-time knowledge of the system's context.

For example, to find the memory usage of a specific service, an engineer needs to know the exact metric name, the label-value pairs, and which specific nodes the service's pods are currently deployed on. Because cloud environments (like Kubernetes) are highly dynamic, this context is constantly changing. Existing text-to-SQL or generic code generation tools often fail in this domain because they lack this hyper-specific, real-time system context.

The PromCopilot Framework

To address the "missing context" problem, we propose PromCopilot, a framework that utilizes a Knowledge Graph-enhanced Retrieval-Augmented Generation (RAG) pipeline to translate natural language into accurate PromQL.

The PromCopilot framework architecture, illustrating the flow from natural language question to PromQL query via knowledge retrieval.

Methodology

The PromCopilot pipeline consists of four primary stages:

  1. System Context Knowledge Graph: Instead of relying on static documentation, PromCopilot automatically constructs a graph combining data from Prometheus (metrics metadata), Kubernetes (infrastructure state), distributed traces (service dependencies), and system documentation.
  2. Question Parsing: When a user asks a question (e.g., "Which node has the most available memory among the nodes where the order service is deployed?"), an LLM parses the prompt to extract component relation paths and metric-component pairs.
  3. Multi-hop Retrieval: Standard RAG often struggles with multi-hop reasoning. PromCopilot uses the parsed paths to traverse the Knowledge Graph—for instance, finding a service, then its associated pods, and finally the specific nodes those pods are hosted on—to retrieve the current system state.
  4. Query Generation: Finally, the retrieved metric definitions and system component relationships are injected into the LLM's prompt to generate the final, context-aware PromQL query.
An example of the reasoning process required to translate a natural language question into a context-aware PromQL query.

Experimental Evaluation

Because text-to-PromQL is a novel task, we developed the first text-to-PromQL benchmark dataset. We deployed TrainTicket, a medium-scale microservice benchmark, on a Kubernetes cluster and collected metrics, traces, and deployment records over seven days. From this, we manually constructed 280 question-PromQL query pairs based on real-world scenarios from official documentation and industrial sources.

Key Results

  • Superior Accuracy: Using GPT-4-Turbo, PromCopilot achieved a 69.1% Query Accuracy. This is a massive leap over basic prompting (2.6%) and even 10-shot learning (37.4%).
  • Open-Source Performance: Using the DeepSeek-Coder-V2-236B model, PromCopilot achieved a competitive 66.9% accuracy, demonstrating the framework's robustness across different LLM backbones.
  • Ablation Insights: Removing system component knowledge from the pipeline dropped accuracy from 69.1% to 12.2%, proving that real-time infrastructure context is the most critical factor for success.

Conclusion and Future Work

PromCopilot demonstrates that while standard LLMs struggle with the dynamic nature of cloud-native monitoring, combining them with a structured Knowledge Graph enables highly accurate automated querying. Future work will focus on scaling the Knowledge Graph retrieval for enterprise-level clusters with tens of thousands of nodes and adapting the framework for other metric languages like InfluxDB's Flux or Azure's Kusto.

Summary updated

BibTeX
@article{zhang2026promcopilot,
  author = {Chenxi Zhang and Bicheng Zhang and Dingyu Yang and Xin Peng and Miao Chen and S. Xie and Gang Chen and Wei Bi and Wei Liu},
  title = {{PromCopilot: Simplifying Prometheus Metric Querying in Cloud Native Online Service Systems via Large Language Models}},
  journal = {ACM Transactions on Software Engineering and Methodology},
  year = {2026},
  doi = {10.1145/3797910},
}
Figure