OpenAI¶
The displayed Metrics of OpenAI include total requests, response time, number of requests, number of request errors, and token consumption.
Configuration{#config}¶
Install Func¶
It is recommended to activate the Guance integration - extensions - DataFlux Func (Automata): all prerequisites are automatically installed, please proceed with the script installation.
If you want to deploy Func yourself, refer to Self-deploy Func
Install DataKit¶
Install the DataKit data collector. In the Guance workspace, click Integration -- Datakit, copy the installation command line to install Datakit.
Note: After installing DataKit, modify one configuration:
- Log in as root and open the DataKit configuration:
vim /usr/local/datakit/conf.d/datakit.conf
- Change
http_listen = "localhost:9529"
tohttp_listen = "0.0.0.0:9529"
- Restart the DataKit service:
datakit service -R
For more information, please refer to:
Install Script¶
Install the corresponding collection script: "Guance Integration (ChatGpt Monitor)" (ID: integration_chatgpt_monitor
)
After clicking [Install], enter the corresponding parameters: OpenAI key.
Click [Integration] - 'Authorization Links' - 'Create', create an authorization link for this function. After creation, you can find this function in the authorization link list. Click the "Example" on the right side of this function, select 'POST Simplified Form (Json)', and you will get a link. Fill this link into the 'url' field in the code.
Verification¶
- In "Management / Automatic Trigger Configuration", confirm whether the corresponding task has the corresponding automatic trigger configuration. At the same time, you can check the corresponding task records and logs to see if there are any exceptions.
- In Guance, check "Metrics" to see if there is corresponding monitoring data.
Metrics¶
Metric | Description | Type | Unit |
---|---|---|---|
question | Total requests | float | count |
response_time | Response time | float | s |
create_time | Number of requests | float | count |
res_status | Number of request errors | float | count |
total_tokens | Total token consumption | float | count |