From 9d8e93ee1ccd1ed54e1566a3ab79ef6e55f12c3a Mon Sep 17 00:00:00 2001
From: noahtalerman <47070608+noahtalerman@users.noreply.github.com>
Date: Mon, 25 Jan 2021 17:08:28 -0800
Subject: [PATCH] Reveal live query error information in Fleet UI (#224)
This PR adds an "Errors" table to the live query UI.
Summary of changes:
- Errors table includes the columns `hostname`, `osquery_version`, and `error`
- The errors table is only rendered when at least one host fails
- Hosts with an osquery version less than 4.4.0 always display the error "upgrade osquery on this host to 4.4.0+ for error details"
---
.../components/hosts/HostsTable/_styles.scss | 2 +-
.../loaders/ProgressBar/_styles.scss | 4 +-
.../QueryProgressDetails.jsx | 22 ++++--
.../queries/QueryProgressDetails/_styles.scss | 42 ++++++++++
.../QueryResultsTable/QueryResultsTable.jsx | 77 +++++++++++++------
.../QueryResultsTable.tests.jsx | 4 +
.../queries/QueryResultsTable/_styles.scss | 65 +++++++++++++---
.../queries/QueryPage/QueryPage.tests.jsx | 10 ++-
.../redux/nodes/entities/campaigns/helpers.js | 38 ++++++++-
frontend/styles/var/colors.scss | 1 +
frontend/test/stubs.js | 4 +
11 files changed, 222 insertions(+), 47 deletions(-)
diff --git a/frontend/components/hosts/HostsTable/_styles.scss b/frontend/components/hosts/HostsTable/_styles.scss
index d14b4b5399..69cad14aa4 100644
--- a/frontend/components/hosts/HostsTable/_styles.scss
+++ b/frontend/components/hosts/HostsTable/_styles.scss
@@ -63,7 +63,7 @@
&--offline {
&:before {
- background-color: $core-red;
+ background-color: $ui-dark-grey;
border-radius: 100%;
content: ' ';
display: inline-block;
diff --git a/frontend/components/loaders/ProgressBar/_styles.scss b/frontend/components/loaders/ProgressBar/_styles.scss
index eac6050d31..fb28b40765 100644
--- a/frontend/components/loaders/ProgressBar/_styles.scss
+++ b/frontend/components/loaders/ProgressBar/_styles.scss
@@ -1,8 +1,10 @@
.progress-bar {
display: flex;
- background-color: $ui-medium-grey;
+ background-color: $ui-dark-grey;
height: 10px;
overflow: hidden;
+ border-radius: 2px;
+ margin-top: 4px;
&__progress {
height: 100%;
diff --git a/frontend/components/queries/QueryProgressDetails/QueryProgressDetails.jsx b/frontend/components/queries/QueryProgressDetails/QueryProgressDetails.jsx
index 7d0babf19a..86adaae10f 100644
--- a/frontend/components/queries/QueryProgressDetails/QueryProgressDetails.jsx
+++ b/frontend/components/queries/QueryProgressDetails/QueryProgressDetails.jsx
@@ -11,9 +11,20 @@ const baseClass = 'query-progress-details';
const QueryProgressDetails = ({ campaign, className, onRunQuery, onStopQuery, queryIsRunning, queryTimerMilliseconds, disableRun }) => {
const { hosts_count: hostsCount } = campaign;
+ const { Metrics: metrics = {} } = campaign;
+ const { errors } = campaign;
const totalHostsCount = get(campaign, ['totals', 'count'], 0);
const totalRowsCount = get(campaign, ['query_results', 'length'], 0);
+ const onlineHostsTotalDisplay = metrics.OnlineHosts === 1 ? '1 host' : `${metrics.OnlineHosts} hosts`;
+ const onlineResultsTotalDisplay = totalRowsCount === 1 ? '1 result' : `${totalRowsCount} results`;
+ const offlineHostsTotalDisplay = metrics.OfflineHosts === 1 ? '1 host' : `${metrics.OfflineHosts} hosts`;
+ const failedHostsTotalDisplay = hostsCount.failed === 1 ? '1 host' : `${hostsCount.failed} hosts`;
+ let totalErrorsDisplay = '0 errors';
+ if (errors) {
+ totalErrorsDisplay = errors.length === 1 ? '1 error' : `${errors.length} errors`;
+ }
+
const runQueryBtn = (