https://signoz.io logo
#support
Title
# support
r

raaja gautam

11/01/2023, 6:30 AM
Hi, we are using signoz for collecting metrics, to track number of success and failure stats of a service. In success metrics as well we have different labels associated with each of the metrics eg: success + "product"(label) success + "cart"(label) we need to create a dashboard based on groupby label, something like this productName success product 1 cart 1 what will be the clickhouse query to get number of success metrics for particular label for a given timestamp window? Note: we tried checking clickhouse tables: signoz_metrics.time_series_v2, signoz_metrics.distributed_samples_v2 but we are not getting the logic, there are multiple entries(repetative) for each fingerprint in signoz_metrics.distributed_samples_v2 table with same value for a given timestamp Query we tried but its showing incorrect value
SELECT productName as productName, (max(value) - min(value)) as Success FROM signoz_metrics.distributed_samples_v2
INNER JOIN
(SELECT  JSONExtractString(labels, 'productName') as productName, fingerprint FROM signoz_metrics.time_series_v2
WHERE metric_name = 'success' AND temporality IN ['Cumulative', 'Unspecified']  as filtered_time_series
USING fingerprint
WHERE timestamp_ms >= ${__from} AND timestamp_ms <= ${__to}
GROUP BY productName ORDER BY productName ASC