forked from phoenix/litellm-mirror
(feat) enable viewing /spend/logs for clickhouse
This commit is contained in:
parent
c1f9703734
commit
30f4033bbc
3 changed files with 14 additions and 8 deletions
|
@ -95,5 +95,18 @@ async def view_spend_logs_from_clickhouse(
|
||||||
10
|
10
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# get size of spend logs
|
||||||
|
num_rows = client.query("SELECT count(*) FROM default.spend_logs")
|
||||||
|
num_rows = num_rows.result_rows[0][0]
|
||||||
|
|
||||||
|
# safely access num_rows.result_rows[0][0]
|
||||||
|
if num_rows is None:
|
||||||
|
num_rows = 0
|
||||||
|
|
||||||
raw_rows = list(response.result_rows)
|
raw_rows = list(response.result_rows)
|
||||||
return raw_rows
|
response_data = {
|
||||||
|
"logs": raw_rows,
|
||||||
|
"log_count": num_rows,
|
||||||
|
}
|
||||||
|
return response_data
|
||||||
|
|
|
@ -85,12 +85,6 @@ def _start_clickhouse():
|
||||||
# check if spend logs exist, if it does then return the schema
|
# check if spend logs exist, if it does then return the schema
|
||||||
response = client.query("DESCRIBE default.spend_logs")
|
response = client.query("DESCRIBE default.spend_logs")
|
||||||
verbose_logger.debug(f"spend logs schema ={response.result_rows}")
|
verbose_logger.debug(f"spend logs schema ={response.result_rows}")
|
||||||
# get all logs from spend logs
|
|
||||||
response = client.query("SELECT * FROM default.spend_logs")
|
|
||||||
verbose_logger.debug(f"spend logs ={response.result_rows}")
|
|
||||||
# get size of spend logs
|
|
||||||
response = client.query("SELECT count(*) FROM default.spend_logs")
|
|
||||||
verbose_logger.debug(f"spend logs count ={response.result_rows}")
|
|
||||||
|
|
||||||
|
|
||||||
class ClickhouseLogger:
|
class ClickhouseLogger:
|
||||||
|
|
|
@ -6016,7 +6016,6 @@ async def health_readiness():
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
index_info = "index does not exist - error: " + str(e)
|
index_info = "index does not exist - error: " + str(e)
|
||||||
cache_type = {"type": cache_type, "index_info": index_info}
|
cache_type = {"type": cache_type, "index_info": index_info}
|
||||||
|
|
||||||
if prisma_client is not None: # if db passed in, check if it's connected
|
if prisma_client is not None: # if db passed in, check if it's connected
|
||||||
await prisma_client.health_check() # test the db connection
|
await prisma_client.health_check() # test the db connection
|
||||||
response_object = {"db": "connected"}
|
response_object = {"db": "connected"}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue