Home/LLM Frameworks/azure-openai-logger
azure-openai-logger logo

azure-openai-logger

Enrichment pending
aavetis/azure-openai-logger

"Batteries included" logging solution for your Azure OpenAI instance.

GraphCanon updated today · GitHub synced today

73
Stars
6
Forks
8
Open issues
2
Watchers
1y
Last push
BicepCreated Sep 5, 2023

Trust & integrity

Full report
Maintenance
Dormant (370d since push)
As of today · Source: github_public_v1
Provenance
Not a fork · Personal account
As of today · Source: github_public_v1
Security (OSV)
No lockfile
As of today · Source: none

Public GitHub metadata and optional OSV dependency scans. Signals, not a guarantee. Trust methodology.

Overview

"Batteries included" logging solution for your Azure OpenAI instance.

Capability facts

Languages
bicep

Source: github.language · Jul 11, 2026

Categories

Compatibility

Sourced claims from the README excerpt - not unsourced marketing copy.

LangChain integrationLangChain

Source: README excerpt (regex_v1, Jul 11, 2026)

examples folder for quickstarts - [**OpenAI**](/examples/openai-example.py), [**Langchain**](/examples/langchain-example.py)
Source link

Tags

README

Observability for your Azure OpenAI instance

Overview and goals

❗️ This project is in "beta"! Please re-review all deployment parameters, code, and queries before using in a production scenario.

This project aims to create a simple and easy to deploy solution to add observability to your Azure OpenAI instance. The approach adds an API Management instance as a proxy for your existing Azure OpenAI service, and funnels logs / requests / responses to an Application Insights instance. Additionally, a prebuilt query is saved to a workbook for easy access to logs.

  • Keep all your OpenAI generations, metrics, and logs in your own Azure subscription.
  • Provision and configure all dependent services programmatically.
  • Queries, workbooks, and visualizations are available out of the box.
  • An overall "batteries included" type of experience.

Usage instructions

  • Pre-requisite: You must have an Azure OpenAI service provisioned already.
  • See the examples folder for quickstarts - OpenAI, Langchain
  • (Recommended) Create a new resource group to house these resources
az group create --name loggerTest --location eastus
  • In the root of this repo, run the deployment script
az deployment group create --resource-group loggerTest \
--template-file ./main.bicep \
--parameters openAiEndpoint="https://your-instance-hostname.openai.azure.com" \
openAiApiKey="your-openai-api-key"
  • Navigate to the API Management instance deployed to your resource group.
  • Copy your new endpoint from APIM and Subscription Key, and replace it in your code. (You can find your Subscription key in Azure API Manager by clicking "Subscriptions", then on the elipsis dots ("...") to the right of OpenAI Subscription, and finally on "Show/hide keys")
// example Javascript code to call your Azure OpenAI instance
const { Configuration } = require("openai");

// add your APIM Subscription Key
const apiKey = process.env.MY_APIM_API_KEY;

config = new Configuration({
  // replace endpoint with your new API Management instance endpoint
  basePath: `https://${APIM_ENDPOINT}/openai/deployments/${OPENAI_DEPLOYMENT_NAME}`,

  // be sure to add headers!
  baseOptions: {
    headers: { "api-key": apiKey },
    params: { "api-version": "2023-07-01-preview" },
  },
});

Advanced usage

With your OpenAI calls, you can provide any amount of custom headers to track usage. For example, tracking how many requests a user makes, or how many calls are on a certain plan, or from a region, or by application.

Provide the custom-headers attribute as a string inside of the headers object:


config = new Configuration({
  basePath: `https://${APIM_ENDPOINT}/openai/deployments/${OPENAI_DEPLOYMENT_NAME}`,

  baseOptions: {
    headers: { 
      "api-key": apiKey,
       "custom-headers": JSON.stringify({
            user: "a_unique_id",
            planId: "your_plan_id",
            region: "your_region",
            application: "my-web-app",
            appVersion: "1.0.0"
          }),
    },
    params: { "api-version": "2023-07-01-preview" },
  },
});

As requests come in, the property dimension dropdown will be populated by the attributes of your custom headers. The values will aggregate the requests that came in with those values.

Debugging issues

  • Test your new endpoint by using the API Management tester (APIM -> APIs -> OpenAI Proxy API -> Test)
    • For deployment-id use a model deployment name you have deployed in Azure Open AI (eg. "gpt-35-turbo")
    • For api-version use the API version you are using (eg. "2023-07-01-preview")
    • If you get a 404, it's likely because the original endpoint you provided was structured incorrectly. Go to Backends -> backend -> Properties - you should see your original endpoint + /openai

Architecture footprint

The main components of the architecture include:

  • API Management (Con