Query metrics
Query metrics: queryMessageMetrics in the TypeScript, Python, Rust and Go clients.
POST /v1/projects/{projectId}/metrics/query
Runs read-only SQL over the Project's message_events or call_events table. Get the SQL schema for supported columns, capabilities, and limits.
photon.projects.queryMessageMetrics(input: QueryMessageMetricsInput, options?: RequestOptions): Promise<QueryMessageMetricsOutput>photon.projects.query_message_metrics(input: QueryMessageMetricsInput, *, options: RequestOptions | None = None) -> models.QueryMessageMetricsResponseclient.query_message_metrics(project_id: String, params: Option<QueryMessageMetricsParams>, body: &types::ClickHouseSqlQueryRequest).await -> Result<ResponseValue<types::QueryMessageMetricsResponse>, Error<QueryMessageMetricsError>>client.Projects.QueryMessageMetrics(ctx context.Context, params *QueryMessageMetricsParams, opts ...RequestOption) (*QueryMessageMetricsResponse, error)import { Photon } from "@photon-ai/api";
const photon = new Photon({
headers: { Authorization: `Bearer ${process.env.PHOTON_API_TOKEN}` },
});
const result = await photon.projects.queryMessageMetrics({
path: {
projectId: "projectId",
},
body: {
sql: "sql",
},
});import os
from photon_api import Photon
from photon_api.rpc_generated import QueryMessageMetricsInput
photon = Photon(headers={"Authorization": f"Bearer {os.environ['PHOTON_API_TOKEN']}"})
result = photon.projects.query_message_metrics(
QueryMessageMetricsInput.model_validate({
"path": {
"projectId": "projectId",
},
"body": {
"sql": "sql",
},
})
)use photon_ai_api::{Credential, PhotonClientBuilder, SecretString};
let token = std::env::var("PHOTON_API_TOKEN")?;
let client = PhotonClientBuilder::new()
.credential("accountServiceKey", Credential::Bearer(SecretString::from(token)))
.build()?;
let result = client
.query_message_metrics(
"projectId".to_owned(),
None,
&serde_json::from_value(serde_json::json!({
"sql": "sql",
}))?,
)
.await
.map_err(|error| format!("{error:?}"))?
.into_inner();import (
"context"
"encoding/json"
"os"
photonapi "github.com/photon-hq/api/packages/go"
)
ctx := context.Background()
client := photonapi.NewClient(photonapi.WithAPIKey(os.Getenv("PHOTON_API_TOKEN")))
var body photonapi.ClickHouseSqlQueryRequest
if err := json.Unmarshal([]byte(`{
"sql": "sql"
}`), &body); err != nil {
return err
}
result, err := client.Projects.QueryMessageMetrics(ctx, &photonapi.QueryMessageMetricsParams{
ProjectID: "projectId",
Body: body,
})
if err != nil {
return err
}
_ = result{
"columns": [
{
"name": "string",
"type": "string"
}
],
"rows": [
[
"string"
]
],
"statistics": {
"bytesRead": 0,
"elapsedSeconds": 0,
"rowsRead": 0
}
}Parameters
API schema date. Defaults to the latest served version; resolves to the latest served date on or before this value.
Body
Returns
200 Dynamic SQL columns and rows followed by bounded ClickHouse read statistics. QueryMessageMetricsResponse