gaarf-exporter

raw JSON →
1.2.1 verified Sat May 09 auth: no python

A Prometheus exporter for Google Ads API metrics, providing real-time monitoring of advertising accounts. Current version 1.2.1, released on 2025-02-15. Active development with irregular releases.

pip install gaarf-exporter
error ModuleNotFoundError: No module named 'gaarf_exporter'
cause Package not installed or wrong Python environment.
fix
Run 'pip install gaarf-exporter' and ensure you are in the correct virtual environment.
error TypeError: __init__() got an unexpected keyword argument 'credential_file'
cause Using old API with credential_file argument removed in v1.2.0.
fix
Use credentials dictionary instead: credentials={'developer_token': ..., 'client_id': ..., ...}
error google.ads.googleads.errors.GoogleAdsException: [quota_failure] Too many requests.
cause Hitting Google Ads API rate limits without backoff.
fix
Implement retry/backoff logic or contact Google to increase quota. Not built-in.
breaking In version 1.2.0 the constructor signature changed: credential_file argument was removed; use credentials dict instead.
fix Replace credential_file='path' with credentials={'developer_token': ..., ...}
gotcha The exporter does not handle Google Ads API quota limits; if you hit rate limits, the exporter may crash with gRPC errors.
fix Implement custom backoff or use gaarf's built-in quota handling. Not configured by default.
gotcha Timeouts are not configurable in the current release; long-running queries may block the exporter HTTP server.
fix Workaround: set a global timeout via Google Ads API client configuration before initializing exporter.

Start a Prometheus exporter that scrapes Google Ads metrics on a schedule.

import os
from gaarf_exporter import GaarfPrometheusExporter
from prometheus_client import start_http_server

# Set credentials via environment variables or Google ADC
exporter = GaarfPrometheusExporter(
    credentials={
        "developer_token": os.environ.get("DEVELOPER_TOKEN", ""),
        "client_id": os.environ.get("CLIENT_ID", ""),
        "client_secret": os.environ.get("CLIENT_SECRET", ""),
        "refresh_token": os.environ.get("REFRESH_TOKEN", "")
    },
    customer_id="123-456-7890"
)

start_http_server(8000)
exporter.run()
print("Serving metrics on :8000")