OpenAI

The OpenAI Platform is a developer-focused environment offering access to OpenAI's advanced AI models via an API.

Available solutions

Zabbix version 8.0
Download

OpenAI Platform by HTTP

Overview

This template is designed for the effortless deployment of OpenAI Platform monitoring by Zabbix via HTTP and doesn't require any external scripts.

Please consult the OpenAI API documentation for more details.

Requirements

Zabbix version: 8.0 and higher.

Tested versions

This template has been tested on:

  • OpenAI Platform

Configuration

Zabbix should be configured according to the instructions in the Templates out of the box section.

Setup

  1. Create an API token (admin key) on the OpenAI Platform page.
  2. Enter the API token into the {$OPENAI.API.TOKEN} macro.

Macros used

Name Description Default
{$OPENAI.API.URL}

OpenAI API URL.

https://api.openai.com/v1
{$OPENAI.TOKEN}

OpenAI API token.

{$OPENAI.TOTAL_EXPENSES.MAX}

Limit on total daily expenses for the entire organization.

1000
{$OPENAI.EXPENSES.MAX}

Limit on daily expenses per project.

100
{$OPENAI.PROJECT.NAME.MATCHES}

This macro is used in OpenAI Platform project discovery. Can be overridden on the host or linked template level.

.*
{$OPENAI.PROJECT.NAME.NOT_MATCHES}

This macro is used in OpenAI Platform project discovery. Can be overridden on the host or linked template level.

CHANGE_IF_NEEDED
{$OPENAI.MODEL.NAME.MATCHES}

This macro is used in OpenAI Platform model discovery. Can be overridden on the host or linked template level.

.*
{$OPENAI.MODEL.NAME.NOT_MATCHES}

This macro is used in OpenAI Platform model discovery. Can be overridden on the host or linked template level.

CHANGE_IF_NEEDED
{$OPENAI.DATA.TIMEOUT}

Response timeout for an API.

15s
{$OPENAI.HTTP_PROXY}

HTTP proxy for API requests. You can specify it using the format [protocol://][username[:password]@]proxy.example.com[:port]. See the documentation at https://www.zabbix.com/documentation/8.0/manual/config/items/itemtypes/http

{$HTTP.TLS.VERIFY}

TLS certificate verification for script items: "none" - disabled, "peer" - verify the certificate chain and expiration, "full" - full verification. Any other value enables full verification. To override the setting for this template only, define the macro with the context "OpenAI Platform", e.g. {$HTTP.TLS.VERIFY:"OpenAI Platform"}.

full

Items

Name Description Type Key and additional info
Daily project count

Total daily project count.

Dependent item openai.daily.project.count

Preprocessing

  • JavaScript: The text is too long. Please see the template.

  • Discard unchanged with heartbeat: 1h

Get data

Item for gathering OpenAI Platform data.

Script openai.platform_data.get
Get data item errors

Item for gathering all the data item errors.

Dependent item openai.platform_data.errors

Preprocessing

  • JSON Path: $.error

    ⛔️Custom on fail: Discard value

  • Discard unchanged with heartbeat: 1h

Get costs

Item for gathering cost data from the OpenAI Platform.

Script openai.costs_data.get
Get cost item errors

Item for gathering all the data item errors.

Dependent item openai.costs_data.errors

Preprocessing

  • JSON Path: $.error

    ⛔️Custom on fail: Discard value

  • Discard unchanged with heartbeat: 1h

Get completions

Item for gathering completion data from the OpenAI Platform.

Script openai.completions_data.get
Get completion item errors

Item for gathering all the data item errors.

Dependent item openai.completions_data.errors

Preprocessing

  • JSON Path: $.error

    ⛔️Custom on fail: Discard value

  • Discard unchanged with heartbeat: 1h

Version

REST API version used for requests.

Dependent item openai.version

Preprocessing

  • JSON Path: $.headers["openai-version"]

    ⛔️Custom on fail: Discard value

  • Discard unchanged with heartbeat: 12h

Total daily expenses

Total amount of expenses for the past day.

Dependent item openai.expenses.total

Preprocessing

  • Discard unchanged with heartbeat: 1d

  • JSON Path: $.costs[0].results..amount.value.sum()

    ⛔️Custom on fail: Set value to: 0

Triggers

Name Description Expression Severity Dependencies and additional info
OpenAI Platform: There are errors in the 'Get data' metric

An error occurred while attempting to retrieve values for the 'Get data' item.

length(last(/OpenAI Platform by HTTP/openai.platform_data.errors))>0 Warning
OpenAI Platform: There are errors in the 'Get costs' metric

An error occurred while attempting to retrieve values for the 'Get costs' item.

length(last(/OpenAI Platform by HTTP/openai.costs_data.errors))>0 Warning
OpenAI Platform: There are errors in the 'Get completions' metric

An error occurred while attempting to retrieve values for the 'Get completions' item.

length(last(/OpenAI Platform by HTTP/openai.completions_data.errors))>0 Warning
OpenAI Platform: Total daily expenses exceeded

The daily expense limit is higher than the maximum.

last(/OpenAI Platform by HTTP/openai.expenses.total)>{$OPENAI.TOTAL_EXPENSES.MAX} Warning Manual close: Yes

LLD rule Project discovery

Name Description Type Key and additional info
Project discovery

Used for discovering projects on the OpenAI Platform.

Dependent item openai.project.discovery

Preprocessing

  • JSON Path: $.projects

    ⛔️Custom on fail: Discard value

Item prototypes for Project discovery

Name Description Type Key and additional info
{#NAME}: Get expense data

Item for gathering expense data for the {#NAME} project.

Dependent item openai.expenses.get[{#ID}]

Preprocessing

  • Discard unchanged with heartbeat: 1d

  • JSON Path: $.costs[0].results..[?(@.project_id == '{#ID}')]

    ⛔️Custom on fail: Set value to: {}

{#NAME}: Daily expenses

Amount of expenses for the past day.

Dependent item openai.expenses.amount[{#ID}]

Preprocessing

  • JSON Path: $..amount.value.sum()

    ⛔️Custom on fail: Set value to: 0

{#NAME}: Get completion data

Item for gathering completion data for the {#NAME} project.

Dependent item openai.completions.get[{#ID}]

Preprocessing

  • Discard unchanged with heartbeat: 1h

  • JSON Path: $.completions..results..[?(@.project_id == '{#ID}')]

    ⛔️Custom on fail: Set value to: {}

{#NAME}: Input tokens

Total number of input tokens received by all models in the project.

Dependent item openai.tokens.input[{#ID}]

Preprocessing

  • JSON Path: $..input_tokens.sum()

    ⛔️Custom on fail: Set value to: 0

{#NAME}: Output tokens

Total number of output tokens sent by all models in the project.

Dependent item openai.tokens.output[{#ID}]

Preprocessing

  • JSON Path: $..output_tokens.sum()

    ⛔️Custom on fail: Set value to: 0

{#NAME}: Input cached tokens

Total number of input cached tokens sent by all models in the project.

Dependent item openai.tokens.input_cached[{#ID}]

Preprocessing

  • JSON Path: $..input_cached_tokens.sum()

    ⛔️Custom on fail: Set value to: 0

{#NAME}: Input audio tokens

Total number of input audio tokens sent by all models in the project.

Dependent item openai.tokens.input_audio[{#ID}]

Preprocessing

  • JSON Path: $..input_audio_tokens.sum()

    ⛔️Custom on fail: Set value to: 0

{#NAME}: Output audio tokens

Total number of output audio tokens sent by all models in the project.

Dependent item openai.tokens.output_audio[{#ID}]

Preprocessing

  • JSON Path: $..output_audio_tokens.sum()

    ⛔️Custom on fail: Set value to: 0

{#NAME}: Model request number

Total number of requests to all models in the project.

Dependent item openai.requests.number[{#ID}]

Preprocessing

  • JSON Path: $..num_model_requests.sum()

    ⛔️Custom on fail: Set value to: 0

Trigger prototypes for Project discovery

Name Description Expression Severity Dependencies and additional info
OpenAI Platform: {#NAME}: Daily expenses exceeded

The daily expense limit for the {#NAME} ({#ID}) project is higher than the maximum.

last(/OpenAI Platform by HTTP/openai.expenses.amount[{#ID}])>{$OPENAI.EXPENSES.MAX:"{#ID}"} Warning Manual close: Yes

LLD rule {#NAME}: Model discovery

Name Description Type Key and additional info
{#NAME}: Model discovery

Used for discovering models used in the {#NAME} project on the OpenAI Platform.

Dependent item openai.model.discovery[{#ID}]

Preprocessing

  • Discard unchanged with heartbeat: 1h

  • JSON Path: $.completions..results[?(@.project_id == '{#ID}')]

    ⛔️Custom on fail: Discard value

Item prototypes for {#NAME}: Model discovery

Name Description Type Key and additional info
{#NAME} [{#MODEL}]: Get model data

Item for gathering data of the {#MODEL} model.

Dependent item openai.model.get[{#ID},"{#MODEL}"]

Preprocessing

  • Discard unchanged with heartbeat: 1h

  • JSON Path: The text is too long. Please see the template.

    ⛔️Custom on fail: Set value to: {}

{#NAME} [{#MODEL}]: Input tokens

Total number of input tokens received by the model {#MODEL} in the {#NAME} project.

Dependent item openai.tokens.input[{#ID},"{#MODEL}"]

Preprocessing

  • JSON Path: $.input_tokens

    ⛔️Custom on fail: Set value to: 0

{#NAME} [{#MODEL}]: Output tokens

Total number of output tokens sent by the model {#MODEL} in the {#NAME} project.

Dependent item openai.tokens.output[{#ID},"{#MODEL}"]

Preprocessing

  • JSON Path: $.output_tokens

    ⛔️Custom on fail: Set value to: 0

{#NAME} [{#MODEL}]: Input cached tokens

Total number of input cached tokens sent by the model {#MODEL} in the {#NAME} project.

Dependent item openai.tokens.input_cached[{#ID},"{#MODEL}"]

Preprocessing

  • JSON Path: $.input_cached_tokens

    ⛔️Custom on fail: Set value to: 0

{#NAME} [{#MODEL}]: Input audio tokens

Total number of input audio tokens sent by the model {#MODEL} in the {#NAME} project.

Dependent item openai.tokens.input_audio[{#ID},"{#MODEL}"]

Preprocessing

  • JSON Path: $.input_audio_tokens

    ⛔️Custom on fail: Set value to: 0

{#NAME} [{#MODEL}]: Output audio tokens

Total number of output audio tokens sent by the model {#MODEL} in the {#NAME} project.

Dependent item openai.tokens.output_audio[{#ID},"{#MODEL}"]

Preprocessing

  • JSON Path: $.output_audio_tokens

    ⛔️Custom on fail: Set value to: 0

{#NAME} [{#MODEL}]: Model request number

Total number of requests to the model {#MODEL} in the {#NAME} project.

Dependent item openai.requests.number[{#ID},"{#MODEL}"]

Preprocessing

  • JSON Path: $.num_model_requests

    ⛔️Custom on fail: Set value to: 0

Feedback

Please report any issues with the template at https://support.zabbix.com

You can also provide feedback, discuss the template, or ask for help at ZABBIX forums

Articles and documentation

+ Propose new article

Не нашли то, что искали?