From 998e72374f742e64565ef15897e55ab1610e1891 Mon Sep 17 00:00:00 2001 From: Srikanth Chekuri Date: Wed, 10 Aug 2022 21:04:12 +0530 Subject: [PATCH 1/3] fix: escape and encode operations regex for overview details (#1499) * fix: interval should be 1d=24h (#1482) (#1483) * fix: escape and encode operations regex for overview details Co-authored-by: Ankit Nayan Co-authored-by: zedongh <248348907@qq.com> --- .../container/MetricsApplication/Tabs/Overview.tsx | 13 +++++++++---- frontend/src/lib/getMinMax.ts | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/frontend/src/container/MetricsApplication/Tabs/Overview.tsx b/frontend/src/container/MetricsApplication/Tabs/Overview.tsx index 2dbf2d33fd..7197887be1 100644 --- a/frontend/src/container/MetricsApplication/Tabs/Overview.tsx +++ b/frontend/src/container/MetricsApplication/Tabs/Overview.tsx @@ -7,7 +7,8 @@ import convertToNanoSecondsToSecond from 'lib/convertToNanoSecondsToSecond'; import { colors } from 'lib/getRandomColor'; import history from 'lib/history'; import { convertRawQueriesToTraceSelectedTags } from 'lib/resourceAttributes'; -import React, { useRef } from 'react'; +import { escapeRegExp } from 'lodash-es'; +import React, { useMemo, useRef } from 'react'; import { useSelector } from 'react-redux'; import { useParams } from 'react-router-dom'; import { AppState } from 'store/reducers'; @@ -29,7 +30,11 @@ function Application({ getWidget }: DashboardProps): JSX.Element { resourceAttributeQueries, topLevelOperations, } = useSelector((state) => state.metrics); - const operationsRegex = topLevelOperations.join('|'); + const operationsRegex = useMemo(() => { + return encodeURIComponent( + topLevelOperations.map((e) => escapeRegExp(e)).join('|'), + ); + }, [topLevelOperations]); const selectedTraceTags: string = JSON.stringify( convertRawQueriesToTraceSelectedTags(resourceAttributeQueries, 'array') || [], @@ -195,7 +200,7 @@ function Application({ getWidget }: DashboardProps): JSX.Element { }} widget={getWidget([ { - query: `sum(rate(signoz_latency_count{service_name="${servicename}", operation=~"${operationsRegex}"${resourceAttributePromQLQuery}}[5m]))`, + query: `sum(rate(signoz_latency_count{service_name="${servicename}", operation=~\`${operationsRegex}\`${resourceAttributePromQLQuery}}[5m]))`, legend: 'Operations', }, ])} @@ -229,7 +234,7 @@ function Application({ getWidget }: DashboardProps): JSX.Element { }} widget={getWidget([ { - query: `max(sum(rate(signoz_calls_total{service_name="${servicename}", operation=~"${operationsRegex}", status_code="STATUS_CODE_ERROR"${resourceAttributePromQLQuery}}[5m]) OR rate(signoz_calls_total{service_name="${servicename}", operation=~"${operationsRegex}", http_status_code=~"5.."${resourceAttributePromQLQuery}}[5m]))*100/sum(rate(signoz_calls_total{service_name="${servicename}", operation=~"${operationsRegex}"${resourceAttributePromQLQuery}}[5m]))) < 1000 OR vector(0)`, + query: `max(sum(rate(signoz_calls_total{service_name="${servicename}", operation=~\`${operationsRegex}\`, status_code="STATUS_CODE_ERROR"${resourceAttributePromQLQuery}}[5m]) OR rate(signoz_calls_total{service_name="${servicename}", operation=~\`${operationsRegex}\`, http_status_code=~"5.."${resourceAttributePromQLQuery}}[5m]))*100/sum(rate(signoz_calls_total{service_name="${servicename}", operation=~\`${operationsRegex}\`${resourceAttributePromQLQuery}}[5m]))) < 1000 OR vector(0)`, legend: 'Error Percentage', }, ])} diff --git a/frontend/src/lib/getMinMax.ts b/frontend/src/lib/getMinMax.ts index ae830cc06a..a597314799 100644 --- a/frontend/src/lib/getMinMax.ts +++ b/frontend/src/lib/getMinMax.ts @@ -30,11 +30,11 @@ const GetMinMax = ( minTime = minTimeAgo; } else if (interval === '1day') { // one day = 24*60(min) - const minTimeAgo = getMinAgo({ minutes: 26 * 60 }).getTime(); + const minTimeAgo = getMinAgo({ minutes: 24 * 60 }).getTime(); minTime = minTimeAgo; } else if (interval === '1week') { // one week = one day * 7 - const minTimeAgo = getMinAgo({ minutes: 26 * 60 * 7 }).getTime(); + const minTimeAgo = getMinAgo({ minutes: 24 * 60 * 7 }).getTime(); minTime = minTimeAgo; } else if (['4hr', '6hr'].includes(interval)) { const h = parseInt(interval.replace('hr', ''), 10); From 54cc3637529d670946e8c97f5f28e18b9a01924e Mon Sep 17 00:00:00 2001 From: Amol Umbark Date: Thu, 11 Aug 2022 13:54:17 +0530 Subject: [PATCH 2/3] Alerts/edit rule issue 676 (#1505) * fix: resolved issue with editing of rules (cherry picked from commit a3015d1077d52db47e3b26572cd625d54e333375) --- pkg/query-service/rules/manager.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/query-service/rules/manager.go b/pkg/query-service/rules/manager.go index bf1e70b956..93ae662c99 100644 --- a/pkg/query-service/rules/manager.go +++ b/pkg/query-service/rules/manager.go @@ -241,6 +241,8 @@ func (m *Manager) EditRule(ruleStr string, id string) error { func (m *Manager) editTask(rule *PostableRule, taskName string) error { m.mtx.Lock() defer m.mtx.Unlock() + + zap.S().Debugf("msg:", "editing a rule task", "\t task name:", taskName) newTask, err := m.prepareTask(false, rule, taskName) @@ -298,12 +300,14 @@ func (m *Manager) DeleteRule(id string) error { func (m *Manager) deleteTask(taskName string) { m.mtx.Lock() defer m.mtx.Unlock() + zap.S().Debugf("msg:", "deleting a rule task", "\t task name:", taskName) oldg, ok := m.tasks[taskName] if ok { oldg.Stop() delete(m.tasks, taskName) delete(m.rules, ruleIdFromTaskName(taskName)) + zap.S().Debugf("msg:", "rule task deleted", "\t task name:", taskName) } else { zap.S().Info("msg: ", "rule not found for deletion", "\t name:", taskName) } @@ -337,6 +341,7 @@ func (m *Manager) addTask(rule *PostableRule, taskName string) error { m.mtx.Lock() defer m.mtx.Unlock() + zap.S().Debugf("msg:", "adding a new rule task", "\t task name:", taskName) newTask, err := m.prepareTask(false, rule, taskName) if err != nil { @@ -605,6 +610,10 @@ func (m *Manager) syncRuleStateWithTask(taskName string, rule *PostableRule) err if err := m.addTask(rule, taskName); err != nil { return err } + } else { + if err := m.editTask(rule, taskName); err != nil { + return err + } } } return nil From 55c9eb733da3c1210ec4319c8ce329570b040d19 Mon Sep 17 00:00:00 2001 From: Prashant Shahi Date: Thu, 11 Aug 2022 14:58:36 +0530 Subject: [PATCH 3/3] =?UTF-8?q?chore(release):=20=F0=9F=93=8C=20pin=20vers?= =?UTF-8?q?ions:=20SigNoz=200.10.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Prashant Shahi --- deploy/docker-swarm/clickhouse-setup/docker-compose.yaml | 4 ++-- deploy/docker/clickhouse-setup/docker-compose.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deploy/docker-swarm/clickhouse-setup/docker-compose.yaml b/deploy/docker-swarm/clickhouse-setup/docker-compose.yaml index 9fbf9e0632..314ab03c0c 100644 --- a/deploy/docker-swarm/clickhouse-setup/docker-compose.yaml +++ b/deploy/docker-swarm/clickhouse-setup/docker-compose.yaml @@ -40,7 +40,7 @@ services: condition: on-failure query-service: - image: signoz/query-service:0.10.1 + image: signoz/query-service:0.10.2 command: ["-config=/root/config/prometheus.yml"] # ports: # - "6060:6060" # pprof port @@ -68,7 +68,7 @@ services: - clickhouse frontend: - image: signoz/frontend:0.10.1 + image: signoz/frontend:0.10.2 deploy: restart_policy: condition: on-failure diff --git a/deploy/docker/clickhouse-setup/docker-compose.yaml b/deploy/docker/clickhouse-setup/docker-compose.yaml index 2892cb89a2..1059cc5f8a 100644 --- a/deploy/docker/clickhouse-setup/docker-compose.yaml +++ b/deploy/docker/clickhouse-setup/docker-compose.yaml @@ -39,7 +39,7 @@ services: # Notes for Maintainers/Contributors who will change Line Numbers of Frontend & Query-Section. Please Update Line Numbers in `./scripts/commentLinesForSetup.sh` & `./CONTRIBUTING.md` query-service: - image: signoz/query-service:0.10.1 + image: signoz/query-service:0.10.2 container_name: query-service command: ["-config=/root/config/prometheus.yml"] # ports: @@ -66,7 +66,7 @@ services: condition: service_healthy frontend: - image: signoz/frontend:0.10.1 + image: signoz/frontend:0.10.2 container_name: frontend restart: on-failure depends_on: