Skip to content

bandoche/zyte-exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zyte Usage Stats Exporter

A Python-based Prometheus exporter that collects usage statistics (requests, costs, status codes) from the Zyte API Dashboard.

This exporter scrapes the Zyte Dashboard API to retrieve daily cumulative metrics (from 00:00 UTC to current time) and exposes them for Prometheus consumption.

License: MIT Python

Features

  • Exports total request counts.
  • Exports total cost (in micro USD).
  • Exports request counts grouped by HTTP status codes.
  • Lightweight and Docker-ready.
  • Handles graceful shutdown (Docker stop).

Prerequisites

To use this exporter, you need credentials from the Zyte Dashboard, not your standard proxy API key.

  1. Organization ID: Found in your dashboard URL (e.g., https://app.zyte.com/o/123456/... -> 123456).
  2. Dashboard API Key: Generate one at Zyte Organization Settings.

Installation & Usage

Option 1: Using Docker (Recommended)

  1. Build the image

    docker build -t zyte-exporter .
  2. Run the container

    docker run -d \
      -p 9188:9188 \
      -e ZYTE_DASHBOARD_API_KEY="YOUR_DASHBOARD_API_KEY" \
      -e ZYTE_ORG_ID="YOUR_ORG_ID" \
      --name zyte-exporter \
      zyte-exporter

Option 2: Running Locally

  1. Install dependencies

    pip install prometheus-client requests
  2. Set environment variables and run

    export ZYTE_DASHBOARD_API_KEY="YOUR_DASHBOARD_API_KEY"
    export ZYTE_ORG_ID="YOUR_ORG_ID"
    
    python zyte_exporter.py

Metrics

The exporter exposes metrics on port 9188 (default).

Metric Name Type Description
zyte_requests_total Counter Total number of requests sent today (UTC).
zyte_cost_microusd_total Counter Total cost incurred today in Micro USD.
zyte_requests_status_total Counter Count of requests grouped by status code (label: code).

Note: Metrics are reset daily at 00:00 UTC by the Zyte API.

Prometheus Configuration

Add the following job to your prometheus.yml:

scrape_configs:
  - job_name: 'zyte-exporter'
    scrape_interval: 60s
    static_configs:
      - targets: ['your-exporter-host:9188']

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Exporter for Zyte

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors