Skip to content

Commit

Permalink
build(docker-compose.yml): add prometheus scraper to docker compose
Browse files Browse the repository at this point in the history
persists prometheus data across restarts
  • Loading branch information
krrishdholakia committed Jul 24, 2024
1 parent ac7f659 commit d9539e5
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
20 changes: 18 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ services:
#########################################
## Uncomment these lines to start proxy with a config.yaml file ##
# volumes:
# - ./proxy_server_config.yaml:/app/config.yaml
# command: [ "--config", "./config.yaml", "--port", "4000"]
###############################################
ports:
- "4000:4000" # Map the container port to the host, change the host port if necessary
Expand All @@ -33,5 +31,23 @@ services:
interval: 1s
timeout: 5s
retries: 10

prometheus:
image: prom/prometheus
volumes:
- prometheus_data:/prometheus
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=15d'
restart: always

volumes:
prometheus_data:
driver: local


# ...rest of your docker-compose config if any
47 changes: 47 additions & 0 deletions litellm/tests/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2560,6 +2560,53 @@ def test_completion_anyscale_with_functions():
# test_completion_anyscale_with_functions()


def test_completion_azure_extra_headers():
# this tests if we can pass api_key to completion, when it's not in the env.
# DO NOT REMOVE THIS TEST. No MATTER WHAT Happens!
# If you want to remove it, speak to Ishaan!
# Ishaan will be very disappointed if this test is removed -> this is a standard way to pass api_key + the router + proxy use this
from httpx import Client
from openai import AzureOpenAI

from litellm.llms.custom_httpx.httpx_handler import HTTPHandler

http_client = Client()

with patch.object(http_client, "send", new=MagicMock()) as mock_client:
client = AzureOpenAI(
azure_endpoint=os.getenv("AZURE_API_BASE"),
api_version=litellm.AZURE_DEFAULT_API_VERSION,
api_key=os.getenv("AZURE_API_KEY"),
http_client=http_client,
)
try:
response = completion(
model="azure/chatgpt-v-2",
messages=messages,
client=client,
extra_headers={
"Authorization": "my-bad-key",
"Ocp-Apim-Subscription-Key": "hello-world-testing",
"api-key": "my-bad-key",
},
)
print(response)
pytest.fail("Expected this to fail")
except Exception as e:
pass

mock_client.assert_called()

print(f"mock_client.call_args: {mock_client.call_args}")
request = mock_client.call_args[0][0]
print(request.method) # This will print 'POST'
print(request.url) # This will print the full URL
print(request.headers) # This will print the full URL
auth_header = request.headers.get("Authorization")
print(auth_header)
assert auth_header == "my-bad-key"


def test_completion_azure_key_completion_arg():
# this tests if we can pass api_key to completion, when it's not in the env.
# DO NOT REMOVE THIS TEST. No MATTER WHAT Happens!
Expand Down
7 changes: 7 additions & 0 deletions prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
global:
scrape_interval: 15s

scrape_configs:
- job_name: 'litellm'
static_configs:
- targets: ['litellm:4000'] # Assuming Litellm exposes metrics at port 4000

0 comments on commit d9539e5

Please sign in to comment.