This is an OpenAI Prometheus Exporter designed to fetch and expose usage data metrics from OpenAI's APIs. The exporter provides metrics related to the utilization of various OpenAI services, such as completions, embeddings, and moderations, suitable for monitoring and analytics purposes.
Before running the exporter, ensure the following environment variables are set:
OPENAI_SECRET_KEY: Your OpenAI API secret key, this can be admin read only keyOPENAI_ORG_ID: Your organization ID with OpenAI, you can see it herego build -o openai-exporter
./openai-exporter
docker run -d -p 9185:9185 -e OPENAI_SECRET_KEY=your_secret_key -e OPENAI_ORG_ID=your_org_id foxdalas/openai-exporter:v0.0.16
Use the following flags to customize the behavior:
-web.listen-address: Set the listen address for the web interface and telemetry (default: :9185).-web.telemetry-path: Set the path under which to expose metrics (default: /metrics).-scrape.interval: Set the interval for API calls and data collection (default: 1m).-log.level: Set the log verbosity (default: info).-scrape.interval)currency label)The exporter provides two main metrics:
openai_api_tokens_totalCounter metric tracking token usage across all operations.
Labels:
model: OpenAI model name (e.g., gpt-4-turbo-2024-04-09)operation: API operation type (e.g., completions, embeddings)project_id: OpenAI project identifierproject_name: Human-readable project name (auto-resolved)user_id: User identifierapi_key_id: API key identifierbatch: Whether the request was batched (true/false)token_type: Type of tokens (input, output, input_cached, input_audio, output_audio)openai_api_daily_costGauge metric tracking daily costs per project.
Labels:
date: Date in YYYY-MM-DD formatproject_id: OpenAI project identifierproject_name: Human-readable project name (auto-resolved)line_item: Cost line item descriptionorganization_id: OpenAI organization identifiercurrency: Currency code (e.g., usd)openai_api_tokens_total{api_key_id="",batch="false",model="gpt-4-turbo-2024-04-09",operation="completions",project_id="",project_name="production",token_type="input",user_id=""} 1081
openai_api_tokens_total{api_key_id="",batch="false",model="gpt-4-turbo-2024-04-09",operation="completions",project_id="",project_name="production",token_type="input_audio",user_id=""} 0
openai_api_tokens_total{api_key_id="",batch="false",model="gpt-4-turbo-2024-04-09",operation="completions",project_id="",project_name="production",token_type="input_cached",user_id=""} 0
openai_api_tokens_total{api_key_id="",batch="false",model="gpt-4-turbo-2024-04-09",operation="completions",project_id="",project_name="production",token_type="output",user_id=""} 1432
openai_api_tokens_total{api_key_id="",batch="false",model="gpt-4-turbo-2024-04-09",operation="completions",project_id="",project_name="production",token_type="output_audio",user_id=""} 0
openai_api_daily_cost{currency="usd",date="2024-01-15",line_item="GPT-4 Turbo",organization_id="org-123",project_id="proj-456",project_name="production"} 42.50
Contributions to the OpenAI Exporter are welcome. Please ensure that your commits meet the following criteria:
This project is licensed under the MIT License - see the LICENSE file for details.
Content type
Image
Digest
sha256:7d947badb…
Size
7.4 MB
Last updated
5 months ago
docker pull foxdalas/openai-exporter:v0.0.16