diff --git a/.github/workflows/remove-label.yaml b/.github/workflows/remove-label.yaml index 6881b9eb77..418475ea23 100644 --- a/.github/workflows/remove-label.yaml +++ b/.github/workflows/remove-label.yaml @@ -11,6 +11,6 @@ jobs: - name: Remove label uses: buildsville/add-remove-label@v1 with: - label: ok-to-test + label: ok-to-test,testing-deploy type: remove token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/staging-deployment.yaml b/.github/workflows/staging-deployment.yaml new file mode 100644 index 0000000000..c655d69df2 --- /dev/null +++ b/.github/workflows/staging-deployment.yaml @@ -0,0 +1,38 @@ +name: staging-deployment +# Trigger deployment only on push to develop branch +on: + push: + branches: + - develop +jobs: + deploy: + name: Deploy latest develop branch to staging + runs-on: ubuntu-latest + environment: staging + steps: + - name: Executing remote ssh commands using ssh key + uses: appleboy/ssh-action@v0.1.6 + env: + GITHUB_BRANCH: develop + GITHUB_SHA: ${{ github.sha }} + with: + host: ${{ secrets.HOST_DNS }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.EC2_SSH_KEY }} + envs: GITHUB_BRANCH,GITHUB_SHA + command_timeout: 60m + script: | + echo "GITHUB_BRANCH: ${GITHUB_BRANCH}" + echo "GITHUB_SHA: ${GITHUB_SHA}" + export DOCKER_TAG="${GITHUB_SHA:0:7}" # needed for child process to access it + docker system prune --force + cd ~/signoz + git status + git add . + git stash push -m "stashed on $(date --iso-8601=seconds)" + git fetch origin + git checkout ${GITHUB_BRANCH} + git pull + make build-ee-query-service-amd64 + make build-frontend-amd64 + make run-signoz \ No newline at end of file diff --git a/.github/workflows/testing-deployment.yaml b/.github/workflows/testing-deployment.yaml new file mode 100644 index 0000000000..d122291d42 --- /dev/null +++ b/.github/workflows/testing-deployment.yaml @@ -0,0 +1,39 @@ +name: testing-deployment +# Trigger deployment only on testing-deploy label on pull request +on: + pull_request: + types: [labeled] +jobs: + deploy: + name: Deploy PR branch to testing + runs-on: ubuntu-latest + environment: testing + if: ${{ github.event.label.name == 'testing-deploy' }} + steps: + - name: Executing remote ssh commands using ssh key + uses: appleboy/ssh-action@v0.1.6 + env: + GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }} + GITHUB_SHA: ${{ github.sha }} + with: + host: ${{ secrets.HOST_DNS }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.EC2_SSH_KEY }} + envs: GITHUB_BRANCH,GITHUB_SHA + command_timeout: 60m + script: | + echo "GITHUB_BRANCH: ${GITHUB_BRANCH}" + echo "GITHUB_SHA: ${GITHUB_SHA}" + export DOCKER_TAG="${GITHUB_SHA:0:7}" # needed for child process to access it + export DEV_BUILD="1" + docker system prune --force + cd ~/signoz + git status + git add . + git stash push -m "stashed on $(date --iso-8601=seconds)" + git fetch origin + git checkout ${GITHUB_BRANCH} + git pull + make build-ee-query-service-amd64 + make build-frontend-amd64 + make run-signoz \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5fd438eda0..e5c2a61bf1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -215,9 +215,26 @@ Please ping us in the [`#contributing`](https://signoz-community.slack.com/archi # 4. Contribute to Backend (Query-Service) 🌑 -[**https://github.com/SigNoz/signoz/tree/develop/pkg/query-service**](https://github.com/SigNoz/signoz/tree/develop/pkg/query-service) +**Need to Update: [https://github.com/SigNoz/signoz/tree/develop/pkg/query-service](https://github.com/SigNoz/signoz/tree/develop/pkg/query-service)** -## 4.1 To run ClickHouse setup (recommended for local development) +## 4.1 Prerequisites + +### 4.1.1 Install SQLite3 + +- Run `sqlite3` command to check if you already have SQLite3 installed on your machine. + +- If not installed already, Install using below command + - on Linux + - on Debian / Ubuntu + ``` + sudo apt install sqlite3 + ``` + - on CentOS / Fedora / RedHat + ``` + sudo yum install sqlite3 + ``` + +## 4.2 To run ClickHouse setup (recommended for local development) - Clone the SigNoz repository and cd into signoz directory, ``` diff --git a/Makefile b/Makefile index d745ec9807..a651c84103 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,7 @@ build-frontend-amd64: @echo "--> Building frontend docker image for amd64" @echo "------------------" @cd $(FRONTEND_DIRECTORY) && \ - docker build --file Dockerfile --no-cache -t $(REPONAME)/$(FRONTEND_DOCKER_IMAGE):$(DOCKER_TAG) \ + docker build --file Dockerfile -t $(REPONAME)/$(FRONTEND_DOCKER_IMAGE):$(DOCKER_TAG) \ --build-arg TARGETPLATFORM="linux/amd64" . # Step to build and push docker image of frontend(used in push pipeline) @@ -54,7 +54,7 @@ build-push-frontend: @echo "--> Building and pushing frontend docker image" @echo "------------------" @cd $(FRONTEND_DIRECTORY) && \ - docker buildx build --file Dockerfile --progress plane --no-cache --push --platform linux/amd64 \ + docker buildx build --file Dockerfile --progress plane --push --platform linux/amd64 \ --tag $(REPONAME)/$(FRONTEND_DOCKER_IMAGE):$(DOCKER_TAG) . # Steps to build and push docker image of query service @@ -65,7 +65,7 @@ build-query-service-amd64: @echo "--> Building query-service docker image for amd64" @echo "------------------" @docker build --file $(QUERY_SERVICE_DIRECTORY)/Dockerfile \ - --no-cache -t $(REPONAME)/$(QUERY_SERVICE_DOCKER_IMAGE):$(DOCKER_TAG) \ + -t $(REPONAME)/$(QUERY_SERVICE_DOCKER_IMAGE):$(DOCKER_TAG) \ --build-arg TARGETPLATFORM="linux/amd64" --build-arg LD_FLAGS="$(LD_FLAGS)" . # Step to build and push docker image of query in amd64 and arm64 (used in push pipeline) @@ -73,7 +73,7 @@ build-push-query-service: @echo "------------------" @echo "--> Building and pushing query-service docker image" @echo "------------------" - @docker buildx build --file $(QUERY_SERVICE_DIRECTORY)/Dockerfile --progress plane --no-cache \ + @docker buildx build --file $(QUERY_SERVICE_DIRECTORY)/Dockerfile --progress plane \ --push --platform linux/arm64,linux/amd64 --build-arg LD_FLAGS="$(LD_FLAGS)" \ --tag $(REPONAME)/$(QUERY_SERVICE_DOCKER_IMAGE):$(DOCKER_TAG) . @@ -84,11 +84,11 @@ build-ee-query-service-amd64: @echo "------------------" @if [ $(DEV_BUILD) != "" ]; then \ docker build --file $(EE_QUERY_SERVICE_DIRECTORY)/Dockerfile \ - --no-cache -t $(REPONAME)/$(QUERY_SERVICE_DOCKER_IMAGE):$(DOCKER_TAG) \ + -t $(REPONAME)/$(QUERY_SERVICE_DOCKER_IMAGE):$(DOCKER_TAG) \ --build-arg TARGETPLATFORM="linux/amd64" --build-arg LD_FLAGS="${LD_FLAGS} ${DEV_LD_FLAGS}" .; \ else \ docker build --file $(EE_QUERY_SERVICE_DIRECTORY)/Dockerfile \ - --no-cache -t $(REPONAME)/$(QUERY_SERVICE_DOCKER_IMAGE):$(DOCKER_TAG) \ + -t $(REPONAME)/$(QUERY_SERVICE_DOCKER_IMAGE):$(DOCKER_TAG) \ --build-arg TARGETPLATFORM="linux/amd64" --build-arg LD_FLAGS="$(LD_FLAGS)" .; \ fi @@ -98,7 +98,7 @@ build-push-ee-query-service: @echo "--> Building and pushing query-service docker image" @echo "------------------" @docker buildx build --file $(EE_QUERY_SERVICE_DIRECTORY)/Dockerfile \ - --progress plane --no-cache --push --platform linux/arm64,linux/amd64 \ + --progress plane --push --platform linux/arm64,linux/amd64 \ --build-arg LD_FLAGS="$(LD_FLAGS)" --tag $(REPONAME)/$(QUERY_SERVICE_DOCKER_IMAGE):$(DOCKER_TAG) . dev-setup: @@ -119,16 +119,19 @@ down-local: $(STANDALONE_DIRECTORY)/docker-compose-core.yaml -f $(STANDALONE_DIRECTORY)/docker-compose-local.yaml \ down -v -run-x86: +pull-signoz: + @docker-compose -f $(STANDALONE_DIRECTORY)/docker-compose.yaml pull + +run-signoz: @docker-compose -f $(STANDALONE_DIRECTORY)/docker-compose.yaml up --build -d -down-x86: +down-signoz: @docker-compose -f $(STANDALONE_DIRECTORY)/docker-compose.yaml down -v clear-standalone-data: @docker run --rm -v "$(PWD)/$(STANDALONE_DIRECTORY)/data:/pwd" busybox \ - sh -c "cd /pwd && rm -rf alertmanager/* clickhous*/* signoz/* zookeeper-*/*" + sh -c "cd /pwd && rm -rf alertmanager/* clickhouse*/* signoz/* zookeeper-*/*" clear-swarm-data: @docker run --rm -v "$(PWD)/$(SWARM_DIRECTORY)/data:/pwd" busybox \ - sh -c "cd /pwd && rm -rf alertmanager/* clickhous*/* signoz/* zookeeper-*/*" + sh -c "cd /pwd && rm -rf alertmanager/* clickhouse*/* signoz/* zookeeper-*/*" diff --git a/deploy/docker-swarm/clickhouse-setup/docker-compose.yaml b/deploy/docker-swarm/clickhouse-setup/docker-compose.yaml index 268b5df1b5..5e2b75c323 100644 --- a/deploy/docker-swarm/clickhouse-setup/docker-compose.yaml +++ b/deploy/docker-swarm/clickhouse-setup/docker-compose.yaml @@ -137,7 +137,7 @@ services: condition: on-failure query-service: - image: signoz/query-service:0.13.0 + image: signoz/query-service:0.13.1 command: ["-config=/root/config/prometheus.yml"] # ports: # - "6060:6060" # pprof port @@ -166,7 +166,7 @@ services: <<: *clickhouse-depend frontend: - image: signoz/frontend:0.13.0 + image: signoz/frontend:0.13.1 deploy: restart_policy: condition: on-failure diff --git a/deploy/docker-swarm/clickhouse-setup/otel-collector-config.yaml b/deploy/docker-swarm/clickhouse-setup/otel-collector-config.yaml index 0636b518cf..91f86b9214 100644 --- a/deploy/docker-swarm/clickhouse-setup/otel-collector-config.yaml +++ b/deploy/docker-swarm/clickhouse-setup/otel-collector-config.yaml @@ -64,7 +64,9 @@ receivers: - job_name: otel-collector static_configs: - targets: - - localhost:8888 + - localhost:8888 + labels: + job_name: otel-collector processors: batch: @@ -104,11 +106,12 @@ exporters: clickhousetraces: datasource: tcp://clickhouse:9000/?database=signoz_traces docker_multi_node_cluster: ${DOCKER_MULTI_NODE_CLUSTER} - clickhousemetricswrite: endpoint: tcp://clickhouse:9000/?database=signoz_metrics resource_to_telemetry_conversion: enabled: true + clickhousemetricswrite/prometheus: + endpoint: tcp://clickhouse:9000/?database=signoz_metrics prometheus: endpoint: 0.0.0.0:8889 # logging: {} @@ -147,9 +150,13 @@ service: processors: [batch] exporters: [clickhousemetricswrite] metrics/generic: - receivers: [hostmetrics, prometheus] + receivers: [hostmetrics] processors: [resourcedetection, batch] exporters: [clickhousemetricswrite] + metrics/prometheus: + receivers: [prometheus] + processors: [batch] + exporters: [clickhousemetricswrite/prometheus] metrics/spanmetrics: receivers: [otlp/spanmetrics] exporters: [prometheus] diff --git a/deploy/docker-swarm/clickhouse-setup/otel-collector-metrics-config.yaml b/deploy/docker-swarm/clickhouse-setup/otel-collector-metrics-config.yaml index 1786eb42e3..099caa737b 100644 --- a/deploy/docker-swarm/clickhouse-setup/otel-collector-metrics-config.yaml +++ b/deploy/docker-swarm/clickhouse-setup/otel-collector-metrics-config.yaml @@ -7,7 +7,9 @@ receivers: scrape_interval: 60s static_configs: - targets: - - localhost:8888 + - localhost:8888 + labels: + job_name: otel-collector-metrics # SigNoz span metrics - job_name: signozspanmetrics-collector scrape_interval: 60s diff --git a/deploy/docker/clickhouse-setup/docker-compose.yaml b/deploy/docker/clickhouse-setup/docker-compose.yaml index 55f9d210f7..17586086df 100644 --- a/deploy/docker/clickhouse-setup/docker-compose.yaml +++ b/deploy/docker/clickhouse-setup/docker-compose.yaml @@ -132,7 +132,7 @@ services: # - ./data/clickhouse-3/:/var/lib/clickhouse/ alertmanager: - image: signoz/alertmanager:0.23.0-0.2 + image: signoz/alertmanager:${ALERTMANAGER_TAG:-0.23.0-0.2} volumes: - ./data/alertmanager:/data depends_on: @@ -146,7 +146,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.13.0 + image: signoz/query-service:${DOCKER_TAG:-0.13.1} container_name: query-service command: ["-config=/root/config/prometheus.yml"] # ports: @@ -174,7 +174,7 @@ services: <<: *clickhouse-depend frontend: - image: signoz/frontend:0.13.0 + image: signoz/frontend:${DOCKER_TAG:-0.13.1} container_name: frontend restart: on-failure depends_on: @@ -186,7 +186,7 @@ services: - ../common/nginx-config.conf:/etc/nginx/conf.d/default.conf otel-collector: - image: signoz/signoz-otel-collector:0.66.1 + image: signoz/signoz-otel-collector:${OTELCOL_TAG:-0.66.1} command: ["--config=/etc/otel-collector-config.yaml"] user: root # required for reading docker container logs volumes: @@ -211,7 +211,7 @@ services: <<: *clickhouse-depend otel-collector-metrics: - image: signoz/signoz-otel-collector:0.66.1 + image: signoz/signoz-otel-collector:${OTELCOL_TAG:-0.66.1} command: ["--config=/etc/otel-collector-metrics-config.yaml"] volumes: - ./otel-collector-metrics-config.yaml:/etc/otel-collector-metrics-config.yaml diff --git a/deploy/docker/clickhouse-setup/otel-collector-config.yaml b/deploy/docker/clickhouse-setup/otel-collector-config.yaml index c6773d187d..969aed20ff 100644 --- a/deploy/docker/clickhouse-setup/otel-collector-config.yaml +++ b/deploy/docker/clickhouse-setup/otel-collector-config.yaml @@ -64,7 +64,10 @@ receivers: - job_name: otel-collector static_configs: - targets: - - localhost:8888 + - localhost:8888 + labels: + job_name: otel-collector + processors: batch: @@ -112,11 +115,12 @@ exporters: clickhousetraces: datasource: tcp://clickhouse:9000/?database=signoz_traces docker_multi_node_cluster: ${DOCKER_MULTI_NODE_CLUSTER} - clickhousemetricswrite: endpoint: tcp://clickhouse:9000/?database=signoz_metrics resource_to_telemetry_conversion: enabled: true + clickhousemetricswrite/prometheus: + endpoint: tcp://clickhouse:9000/?database=signoz_metrics prometheus: endpoint: 0.0.0.0:8889 # logging: {} @@ -151,9 +155,13 @@ service: processors: [batch] exporters: [clickhousemetricswrite] metrics/generic: - receivers: [hostmetrics, prometheus] + receivers: [hostmetrics] processors: [resourcedetection, batch] exporters: [clickhousemetricswrite] + metrics/prometheus: + receivers: [prometheus] + processors: [batch] + exporters: [clickhousemetricswrite/prometheus] metrics/spanmetrics: receivers: [otlp/spanmetrics] exporters: [prometheus] diff --git a/deploy/docker/clickhouse-setup/otel-collector-metrics-config.yaml b/deploy/docker/clickhouse-setup/otel-collector-metrics-config.yaml index aecad4eaaf..7543d1f6f6 100644 --- a/deploy/docker/clickhouse-setup/otel-collector-metrics-config.yaml +++ b/deploy/docker/clickhouse-setup/otel-collector-metrics-config.yaml @@ -11,7 +11,9 @@ receivers: scrape_interval: 60s static_configs: - targets: - - localhost:8888 + - localhost:8888 + labels: + job_name: otel-collector-metrics # SigNoz span metrics - job_name: signozspanmetrics-collector scrape_interval: 60s diff --git a/ee/query-service/app/server.go b/ee/query-service/app/server.go index 0d92d8be82..f6f1726b95 100644 --- a/ee/query-service/app/server.go +++ b/ee/query-service/app/server.go @@ -1,8 +1,11 @@ package app import ( + "bytes" "context" + "encoding/json" "fmt" + "io/ioutil" "net" "net/http" _ "net/http/pprof" // http profiler @@ -266,15 +269,82 @@ func (lrw *loggingResponseWriter) Flush() { lrw.ResponseWriter.(http.Flusher).Flush() } +func extractDashboardMetaData(path string, r *http.Request) (map[string]interface{}, bool) { + pathToExtractBodyFrom := "/api/v2/metrics/query_range" + var requestBody map[string]interface{} + data := map[string]interface{}{} + + if path == pathToExtractBodyFrom && (r.Method == "POST") { + bodyBytes, _ := ioutil.ReadAll(r.Body) + r.Body.Close() // must close + r.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes)) + + json.Unmarshal(bodyBytes, &requestBody) + + } else { + return nil, false + } + + compositeMetricQuery, compositeMetricQueryExists := requestBody["compositeMetricQuery"] + compositeMetricQueryMap := compositeMetricQuery.(map[string]interface{}) + signozMetricFound := false + + if compositeMetricQueryExists { + signozMetricFound = telemetry.GetInstance().CheckSigNozMetrics(compositeMetricQueryMap) + queryType, queryTypeExists := compositeMetricQueryMap["queryType"] + if queryTypeExists { + data["queryType"] = queryType + } + panelType, panelTypeExists := compositeMetricQueryMap["panelType"] + if panelTypeExists { + data["panelType"] = panelType + } + } + + datasource, datasourceExists := requestBody["dataSource"] + if datasourceExists { + data["datasource"] = datasource + } + + if !signozMetricFound { + telemetry.GetInstance().AddActiveMetricsUser() + telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_EVENT_DASHBOARDS_METADATA, data, true) + } + + return data, true +} + +func getActiveLogs(path string, r *http.Request) { + // if path == "/api/v1/dashboards/{uuid}" { + // telemetry.GetInstance().AddActiveMetricsUser() + // } + if path == "/api/v1/logs" { + hasFilters := len(r.URL.Query().Get("q")) + if hasFilters > 0 { + telemetry.GetInstance().AddActiveLogsUser() + } + + } + +} + func (s *Server) analyticsMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { route := mux.CurrentRoute(r) path, _ := route.GetPathTemplate() + dashboardMetadata, metadataExists := extractDashboardMetaData(path, r) + getActiveLogs(path, r) + lrw := NewLoggingResponseWriter(w) next.ServeHTTP(lrw, r) data := map[string]interface{}{"path": path, "statusCode": lrw.statusCode} + if metadataExists { + for key, value := range dashboardMetadata { + data[key] = value + } + } if _, ok := telemetry.IgnoredPaths()[path]; !ok { telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_EVENT_PATH, data) diff --git a/frontend/src/container/AllError/index.tsx b/frontend/src/container/AllError/index.tsx index 5d4a6367b3..e7f2e64bcc 100644 --- a/frontend/src/container/AllError/index.tsx +++ b/frontend/src/container/AllError/index.tsx @@ -108,12 +108,21 @@ function AllErrors(): JSX.Element { enabled: !loading, }, { - queryKey: ['getErrorCounts', maxTime, minTime], + queryKey: [ + 'getErrorCounts', + maxTime, + minTime, + getUpdatedExceptionType, + getUpdatedServiceName, + ], queryFn: (): Promise> => getErrorCounts({ end: maxTime, start: minTime, + exceptionType: getUpdatedExceptionType, + serviceName: getUpdatedServiceName, }), + enabled: !loading, }, ]); diff --git a/frontend/src/container/LogControls/config.ts b/frontend/src/container/LogControls/config.ts new file mode 100644 index 0000000000..7d3b0f71ee --- /dev/null +++ b/frontend/src/container/LogControls/config.ts @@ -0,0 +1 @@ +export const ITEMS_PER_PAGE_OPTIONS = [25, 50, 100, 200]; diff --git a/frontend/src/container/LogControls/index.tsx b/frontend/src/container/LogControls/index.tsx index ef8b8819a8..319b9b5f0d 100644 --- a/frontend/src/container/LogControls/index.tsx +++ b/frontend/src/container/LogControls/index.tsx @@ -4,7 +4,7 @@ import { RightOutlined, } from '@ant-design/icons'; import { Button, Divider, Select } from 'antd'; -import React, { memo } from 'react'; +import React, { memo, useMemo } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { AppState } from 'store/reducers'; import { @@ -15,16 +15,19 @@ import { } from 'types/actions/logs'; import { ILogsReducer } from 'types/reducer/logs'; +import { ITEMS_PER_PAGE_OPTIONS } from './config'; import { Container } from './styles'; const { Option } = Select; -const ITEMS_PER_PAGE_OPTIONS = [25, 50, 100, 200]; - function LogControls(): JSX.Element | null { - const { logLinesPerPage, liveTail } = useSelector( - (state) => state.logs, - ); + const { + logLinesPerPage, + liveTail, + isLoading: isLogsLoading, + isLoadingAggregate, + logs, + } = useSelector((state) => state.logs); const dispatch = useDispatch(); const handleLogLinesPerPageChange = (e: number): void => { @@ -51,29 +54,58 @@ function LogControls(): JSX.Element | null { }); }; + const isLoading = isLogsLoading || isLoadingAggregate; + + const isNextAndPreviousDisabled = useMemo( + () => + isLoading || + logLinesPerPage === 0 || + logs.length === 0 || + logs.length < logLinesPerPage, + [isLoading, logLinesPerPage, logs.length], + ); + if (liveTail !== 'STOPPED') { return null; } + return ( - - - ); diff --git a/frontend/src/container/LogsAggregate/index.tsx b/frontend/src/container/LogsAggregate/index.tsx index 34200049c4..66a16f9ad3 100644 --- a/frontend/src/container/LogsAggregate/index.tsx +++ b/frontend/src/container/LogsAggregate/index.tsx @@ -3,7 +3,7 @@ import Graph from 'components/Graph'; import Spinner from 'components/Spinner'; import dayjs from 'dayjs'; import getStep from 'lib/getStep'; -import React, { memo, useEffect, useRef } from 'react'; +import React, { memo, useEffect, useMemo, useRef } from 'react'; import { connect, useSelector } from 'react-redux'; import { bindActionCreators, Dispatch } from 'redux'; import { ThunkDispatch } from 'redux-thunk'; @@ -77,6 +77,18 @@ function LogsAggregate({ getLogsAggregate }: LogsAggregateProps): JSX.Element { // eslint-disable-next-line react-hooks/exhaustive-deps }, [getLogsAggregate, maxTime, minTime, liveTail]); + const graphData = useMemo(() => { + return { + labels: logsAggregate.map((s) => new Date(s.timestamp / 1000000)), + datasets: [ + { + data: logsAggregate.map((s) => s.value), + backgroundColor: blue[4], + }, + ], + }; + }, [logsAggregate]); + return ( {isLoadingAggregate ? ( @@ -84,15 +96,7 @@ function LogsAggregate({ getLogsAggregate }: LogsAggregateProps): JSX.Element { ) : ( new Date(s.timestamp / 1000000)), - datasets: [ - { - data: logsAggregate.map((s) => s.value), - backgroundColor: blue[4], - }, - ], - }} + data={graphData} type="bar" containerHeight="100%" animate diff --git a/frontend/src/container/LogsSearchFilter/index.tsx b/frontend/src/container/LogsSearchFilter/index.tsx index b5cb71faa9..5f2c6d482d 100644 --- a/frontend/src/container/LogsSearchFilter/index.tsx +++ b/frontend/src/container/LogsSearchFilter/index.tsx @@ -16,7 +16,12 @@ import { getLogs } from 'store/actions/logs/getLogs'; import { getLogsAggregate } from 'store/actions/logs/getLogsAggregate'; import { AppState } from 'store/reducers'; import AppActions from 'types/actions'; -import { FLUSH_LOGS, TOGGLE_LIVE_TAIL } from 'types/actions/logs'; +import { + FLUSH_LOGS, + SET_LOADING, + SET_LOADING_AGGREGATE, + TOGGLE_LIVE_TAIL, +} from 'types/actions/logs'; import { GlobalReducer } from 'types/reducer/globalTime'; import { ILogsReducer } from 'types/reducer/logs'; @@ -120,14 +125,33 @@ function SearchFilter({ const urlQuery = useUrlQuery(); const urlQueryString = urlQuery.get('q'); - const debouncedHandleSearch = useMemo(() => debounce(handleSearch, 600), [ - handleSearch, - ]); - useEffect(() => { + dispatch({ + type: SET_LOADING, + payload: true, + }); + dispatch({ + type: SET_LOADING_AGGREGATE, + payload: true, + }); + + const debouncedHandleSearch = debounce(handleSearch, 600); + debouncedHandleSearch(urlQueryString || ''); + + return (): void => { + debouncedHandleSearch.cancel(); + }; // eslint-disable-next-line react-hooks/exhaustive-deps - }, [urlQueryString, maxTime, minTime, idEnd, idStart, logLinesPerPage]); + }, [ + urlQueryString, + maxTime, + minTime, + idEnd, + idStart, + logLinesPerPage, + dispatch, + ]); return ( @@ -161,7 +185,6 @@ function SearchFilter({ debouncedupdateQueryString(value); }} allowClear - onSearch={handleSearch} /> @@ -169,12 +192,8 @@ function SearchFilter({ } interface DispatchProps { - getLogs: ( - props: Parameters[0], - ) => (dispatch: Dispatch) => void; - getLogsAggregate: ( - props: Parameters[0], - ) => (dispatch: Dispatch) => void; + getLogs: typeof getLogs; + getLogsAggregate: typeof getLogsAggregate; } type SearchFilterProps = DispatchProps; diff --git a/frontend/src/container/OrganizationSettings/DisplayName/index.tsx b/frontend/src/container/OrganizationSettings/DisplayName/index.tsx index 32b520cb4f..1497232fee 100644 --- a/frontend/src/container/OrganizationSettings/DisplayName/index.tsx +++ b/frontend/src/container/OrganizationSettings/DisplayName/index.tsx @@ -79,7 +79,7 @@ function DisplayName({ />