INNER CODE UNIT · Python
make_prometheus_request
pab1it0/prometheus-mcp-server · src/prometheus_mcp_server/server.py:189
def make_prometheus_request(endpoint, params=None):
"""Make a request to the Prometheus API with proper authentication and headers."""
if not config.url:
logger.error("Prometheus configuration missing", error="PROMETHEUS_URL not set")
raise ValueError("Prometheus configuration is missing. Please set PROMETHEUS_URL environment variable.")
if not config.url_ssl_verify:
logger.warning("SSL certificate verification is disabled. This is insecure and should not be used in production environments.", endpoint=endpoint)
url = f"{config.url.rstrip('/')}/api/v1/{endpoint}"
url_ssl_verify = config.url_ssl_verify
auth = get_prometheus_auth()
headers = {}
if isinstance(auth, dict): # Token auth is passed via headers
headers.update(auth)
auth = None # Clear auth for requests.get if it's already in headers
# Add OrgID header if specified