feat(chalice): changed errors_per_domains to use requests only instead of all resources
This commit is contained in:
parent
2393af2290
commit
8c7c25e7cd
2 changed files with 12 additions and 12 deletions
|
|
@ -1719,15 +1719,15 @@ def get_slowest_domains(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
|||
def get_errors_per_domains(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
||||
endTimestamp=TimeUTC.now(), **args):
|
||||
pg_sub_query = __get_constraints(project_id=project_id, data=args)
|
||||
pg_sub_query.append("resources.success = FALSE")
|
||||
pg_sub_query.append("requests.success = FALSE")
|
||||
|
||||
with pg_client.PostgresClient() as cur:
|
||||
pg_query = f"""SELECT
|
||||
resources.url_host AS domain,
|
||||
COUNT(resources.session_id) AS errors_count
|
||||
FROM events.resources INNER JOIN sessions USING (session_id)
|
||||
requests.host AS domain,
|
||||
COUNT(requests.session_id) AS errors_count
|
||||
FROM events_common.requests INNER JOIN sessions USING (session_id)
|
||||
WHERE {" AND ".join(pg_sub_query)}
|
||||
GROUP BY resources.url_host
|
||||
GROUP BY requests.host
|
||||
ORDER BY errors_count DESC
|
||||
LIMIT 5;"""
|
||||
cur.execute(cur.mogrify(pg_query, {"project_id": project_id,
|
||||
|
|
|
|||
|
|
@ -1684,19 +1684,19 @@ def get_slowest_domains(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
|||
|
||||
def get_errors_per_domains(project_id, startTimestamp=TimeUTC.now(delta_days=-1),
|
||||
endTimestamp=TimeUTC.now(), **args):
|
||||
raise Exception("not supported widget")
|
||||
ch_sub_query = __get_basic_constraints(table_name="resources", data=args)
|
||||
ch_sub_query.append("resources.success = 0")
|
||||
ch_sub_query = __get_basic_constraints(table_name="requests", data=args)
|
||||
ch_sub_query.append("requests.event_type = 'REQUEST'")
|
||||
ch_sub_query.append("requests.success = 0")
|
||||
meta_condition = __get_meta_constraint(args)
|
||||
ch_sub_query += meta_condition
|
||||
|
||||
with ch_client.ClickHouseClient() as ch:
|
||||
ch_query = f"""SELECT
|
||||
resources.url_host AS domain,
|
||||
COUNT(resources.session_id) AS errors_count
|
||||
FROM resources {"INNER JOIN sessions_metadata USING(session_id)" if len(meta_condition) > 0 else ""}
|
||||
requests.url_host AS domain,
|
||||
COUNT(requests.session_id) AS errors_count
|
||||
FROM {sessions_helper.get_main_events_table(startTimestamp)} AS requests
|
||||
WHERE {" AND ".join(ch_sub_query)}
|
||||
GROUP BY resources.url_host
|
||||
GROUP BY requests.url_host
|
||||
ORDER BY errors_count DESC
|
||||
LIMIT 5;"""
|
||||
rows = ch.execute(query=ch_query,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue