diff --git a/.circleci/config.yml b/.circleci/config.yml index bcba211060..f1cbd0320b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,6 +4,13 @@ orbs: aws-s3: circleci/aws-s3@2.0.0 +parameters: + trigger: + type: enum + enum: [none, deploy-as-artifacts] + default: none + + workflows: version: 2 main: @@ -69,6 +76,15 @@ workflows: tags: only: /^[0-9]+(\.[0-9]+)*$/ + trigger: + when: + equal: [ deploy-as-artifacts, << pipeline.parameters.trigger >> ] + jobs: + - build + - build-nightly: + requires: + - build + jobs: build: environment: @@ -123,6 +139,27 @@ jobs: - store_artifacts: path: ./build/ + build-nightly: + environment: + DOCKER_TAG: chronograf-20240919 + GO111MODULE: "ON" + machine: + image: ubuntu-2204:current + steps: + - attach_workspace: + at: /home/circleci + - run: | + ./etc/scripts/docker/run.sh \ + --debug \ + --clean \ + --package \ + --platform all \ + --arch all \ + --nightly \ + --version=${CIRCLE_SHA1:0:7} + - store_artifacts: + path: ./build/ + deploy-pre-release: environment: DOCKER_TAG: chronograf-20240919 diff --git a/CHANGELOG.md b/CHANGELOG.md index 30bb8d26b1..425fbf5ddc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Bug Fixes 1. [#6103](https://github.com/influxdata/chronograf/pull/6103): Set active database for InfluxQL meta queries. +1. [#6111](https://github.com/influxdata/chronograf/pull/6111): Fix loading Hosts page for large number of hosts. ### Other diff --git a/docs/images/testing-builds-pipeline.png b/docs/images/testing-builds-pipeline.png new file mode 100644 index 0000000000..8c1c4a1dfe Binary files /dev/null and b/docs/images/testing-builds-pipeline.png differ diff --git a/docs/images/testing-builds-result.png b/docs/images/testing-builds-result.png new file mode 100644 index 0000000000..02f8936e85 Binary files /dev/null and b/docs/images/testing-builds-result.png differ diff --git a/docs/release.md b/docs/release.md index 97ac904a9e..5faf6bac23 100644 --- a/docs/release.md +++ b/docs/release.md @@ -50,4 +50,19 @@ git push --tags * OS X * amd64 * Windows - * amd64 \ No newline at end of file + * amd64 + +## Testing builds + +The test builds are stored as artifacts on the CircleCI build page. If you want to create a test build, you can do it by triggering a pipeline on CircleCI. +During the trigger of the pipeline, you should specify the `trigger` parameter with the value `deploy-as-artifacts`: + +

+ +

+ +The resulting artifacts will be available on the CircleCI build page for `build-nightly` Job: + +

+ +

\ No newline at end of file diff --git a/ui/src/hosts/apis/index.ts b/ui/src/hosts/apis/index.ts index 16e9b2080d..0e3b13903d 100644 --- a/ui/src/hosts/apis/index.ts +++ b/ui/src/hosts/apis/index.ts @@ -49,13 +49,13 @@ export const getCpuAndLoadForHosts = async ( tempVars: Template[] ): Promise => { const query = replaceTemplate( - `SELECT mean("usage_user") FROM \":db:\".\":rp:\".\"cpu\" WHERE "cpu" = 'cpu-total' AND time > now() - 10m GROUP BY host; + `SHOW TAG VALUES WITH KEY = "host" WHERE TIME > now() - 10m; + SELECT mean("usage_user") FROM \":db:\".\":rp:\".\"cpu\" WHERE "cpu" = 'cpu-total' AND time > now() - 10m GROUP BY host; SELECT mean("load1") FROM \":db:\".\":rp:\".\"system\" WHERE time > now() - 10m GROUP BY host; SELECT non_negative_derivative(mean(uptime)) AS deltaUptime FROM \":db:\".\":rp:\".\"system\" WHERE time > now() - ${telegrafSystemInterval} * 10 GROUP BY host, time(${telegrafSystemInterval}) fill(0); SELECT mean("Percent_Processor_Time") FROM \":db:\".\":rp:\".\"win_cpu\" WHERE time > now() - 10m GROUP BY host; SELECT mean("Processor_Queue_Length") FROM \":db:\".\":rp:\".\"win_system\" WHERE time > now() - 10m GROUP BY host; - SELECT non_negative_derivative(mean("System_Up_Time")) AS winDeltaUptime FROM \":db:\".\":rp:\".\"win_system\" WHERE time > now() - ${telegrafSystemInterval} * 10 GROUP BY host, time(${telegrafSystemInterval}) fill(0); - SHOW TAG VALUES WITH KEY = "host" WHERE TIME > now() - 10m;`, + SELECT non_negative_derivative(mean("System_Up_Time")) AS winDeltaUptime FROM \":db:\".\":rp:\".\"win_system\" WHERE time > now() - ${telegrafSystemInterval} * 10 GROUP BY host, time(${telegrafSystemInterval}) fill(0);`, tempVars ) @@ -65,15 +65,19 @@ export const getCpuAndLoadForHosts = async ( db: telegrafDB, }) + return parseHostsObject(data) +} + +export const parseHostsObject = (data: any): HostsObject => { const hosts: HostsObject = {} const precision = 100 - const cpuSeries = getDeep(data, 'results.[0].series', []) - const loadSeries = getDeep(data, 'results.[1].series', []) - const uptimeSeries = getDeep(data, 'results.[2].series', []) - const winCPUSeries = getDeep(data, 'results.[3].series', []) - const winLoadSeries = getDeep(data, 'results.[4].series', []) - const winUptimeSeries = getDeep(data, 'results.[5].series', []) - const allHostsSeries = getDeep(data, 'results.[6].series', []) + const allHostsSeries = getDeep(data, 'results.[0].series', []) + const cpuSeries = getDeep(data, 'results.[1].series', []) + const loadSeries = getDeep(data, 'results.[2].series', []) + const uptimeSeries = getDeep(data, 'results.[3].series', []) + const winCPUSeries = getDeep(data, 'results.[4].series', []) + const winLoadSeries = getDeep(data, 'results.[5].series', []) + const winUptimeSeries = getDeep(data, 'results.[6].series', []) allHostsSeries.forEach(s => { const hostnameIndex = s.columns.findIndex(col => col === 'value') diff --git a/ui/test/hosts/containers/HostsPage.test.tsx b/ui/test/hosts/containers/HostsPage.test.tsx index 75a47af9d6..4222abdc85 100644 --- a/ui/test/hosts/containers/HostsPage.test.tsx +++ b/ui/test/hosts/containers/HostsPage.test.tsx @@ -12,6 +12,7 @@ jest.mock('src/hosts/apis', () => require('mocks/hosts/apis')) jest.mock('src/shared/apis/env', () => require('mocks/shared/apis/env')) import {getCpuAndLoadForHosts} from 'src/hosts/apis' +const {parseHostsObject} = jest.requireActual('src/hosts/apis') const setup = (override = {}) => { const props = { @@ -64,3 +65,168 @@ describe('Hosts.Containers.HostsPage', () => { }) }) }) + +describe('Parsing HostsObject', () => { + let cpu_load_hosts + + beforeEach(() => { + cpu_load_hosts = { + results: [ + { + statement_id: 0, + series: [ + { + name: 'cpu', + columns: ['key', 'value'], + values: [['host', 'my-host1']], + }, + { + name: 'db_query', + columns: ['key', 'value'], + values: [['host', 'my-host2']], + }, + ], + }, + { + statement_id: 1, + series: [ + { + name: 'cpu', + tags: {host: 'my-host1'}, + columns: ['time', 'mean'], + values: [[1718874564091, 2.2943182130124]], + }, + { + name: 'cpu', + tags: {host: 'my-host2'}, + columns: ['time', 'mean'], + values: [[1718874564092, 4.2943182130124]], + }, + ], + }, + { + statement_id: 2, + series: [ + { + name: 'system', + tags: {host: 'my-host1'}, + columns: ['time', 'mean'], + values: [[1718874564111, 1.5699999999999]], + }, + { + name: 'system', + tags: {host: 'my-host2'}, + columns: ['time', 'mean'], + values: [[1718874564112, 2.5699999999999]], + }, + ], + }, + { + statement_id: 3, + series: [ + { + name: 'system', + tags: {host: 'my-host1'}, + columns: ['time', 'deltaUptime'], + values: [ + [1718874540001, 753231], + [1718874600001, 60], + [1718874660001, 60], + [1718874720001, 60], + [1718874780001, 60], + [1718874840001, 60], + [1718874900001, 60], + [1718874960001, 60], + [1718875020001, 60], + [1718875080001, 60], + [1718875140001, 60], + ], + }, + { + name: 'system', + tags: {host: 'my-host2'}, + columns: ['time', 'deltaUptime'], + values: [ + [2718874540002, 753232], + [2718874600002, 60], + [2718874660002, 60], + [2718874720002, 60], + [2718874780002, 60], + [2718874840002, 60], + [2718874900002, 60], + [2718874960002, 60], + [2718875020002, 60], + [2718875080002, 60], + [2718875140002, 70], + ], + }, + ], + }, + {statement_id: 4}, + {statement_id: 5}, + {statement_id: 6}, + ], + uuid: '123456789', + } + }) + + it('parse', () => { + const hosts = parseHostsObject(cpu_load_hosts) + expect(hosts['my-host1']).toStrictEqual({ + name: 'my-host1', + cpu: 2.29, + load: 1.57, + deltaUptime: 60, + apps: [], + }) + expect(hosts['my-host2']).toStrictEqual({ + name: 'my-host2', + cpu: 4.29, + load: 2.57, + deltaUptime: 70, + apps: [], + }) + expect(hosts['my-host3']).toBeUndefined() + }) + it('missing in cpu', () => { + cpu_load_hosts.results[1].series = [cpu_load_hosts.results[1].series[0]] + const hosts = parseHostsObject(cpu_load_hosts) + expect(hosts['my-host1']).toBeDefined() + expect(hosts['my-host1']).toStrictEqual({ + name: 'my-host1', + cpu: 2.29, + load: 1.57, + deltaUptime: 60, + apps: [], + }) + expect(hosts['my-host2']).toStrictEqual({ + name: 'my-host2', + cpu: 0, + load: 2.57, + deltaUptime: 70, + apps: [], + }) + expect(hosts['my-host3']).toBeUndefined() + }) + it('missing in host', () => { + const series = cpu_load_hosts.results[0].series[0] + cpu_load_hosts.results[0].series = [series] + const hosts = parseHostsObject(cpu_load_hosts) + expect(hosts['my-host1']).toBeDefined() + expect(hosts['my-host1']).toStrictEqual({ + name: 'my-host1', + cpu: 2.29, + load: 1.57, + deltaUptime: 60, + apps: [], + }) + expect(hosts['my-host2']).toStrictEqual({ + name: 'my-host2', + cpu: 4.29, + load: 2.57, + deltaUptime: 70, + apps: [], + }) + expect(hosts['my-host3']).toBeUndefined() + }) +})