From f8f7b97b82040eab1a6e8d47b0acf8dec83dc0d3 Mon Sep 17 00:00:00 2001 From: Hunter Trujillo Date: Wed, 8 Nov 2017 16:00:24 -0700 Subject: [PATCH] Address some issues in PR. --- ui/src/kapacitor/apis/index.js | 12 + ui/src/kapacitor/components/LogsTable.js | 6 +- ui/src/kapacitor/constants/dummyLogs.js | 1323 ----------------- ui/src/kapacitor/containers/TickscriptPage.js | 34 +- ui/src/shared/components/ResizeContainer.js | 8 +- ui/src/shared/components/ResizeHandle.js | 6 +- 6 files changed, 37 insertions(+), 1352 deletions(-) delete mode 100644 ui/src/kapacitor/constants/dummyLogs.js diff --git a/ui/src/kapacitor/apis/index.js b/ui/src/kapacitor/apis/index.js index d24847f279..7b218c03bd 100644 --- a/ui/src/kapacitor/apis/index.js +++ b/ui/src/kapacitor/apis/index.js @@ -100,3 +100,15 @@ export const updateTask = async ( throw error } } + +export const getLogStream = kapacitor => + fetch(`${kapacitor.links.proxy}?path=/kapacitor/v1/logs`, { + method: 'GET', + headers: {'Content-Type': 'application/json'}, + }) + +export const getLogStreamByRuleID = (kapacitor, ruleID) => + fetch(`${kapacitor.links.proxy}?path=/kapacitor/v1/logs?task=${ruleID}`, { + method: 'GET', + headers: {'Content-Type': 'application/json'}, + }) diff --git a/ui/src/kapacitor/components/LogsTable.js b/ui/src/kapacitor/components/LogsTable.js index 0334afb006..b16de6f40e 100644 --- a/ui/src/kapacitor/components/LogsTable.js +++ b/ui/src/kapacitor/components/LogsTable.js @@ -20,7 +20,7 @@ class LogsTable extends Component { return objElements } - renderTableRow = (logItem, i) => { + renderTableRow = logItem => { let rowDetails if (logItem.service === 'sessions') { @@ -111,7 +111,7 @@ class LogsTable extends Component { } return ( -
+
@@ -140,7 +140,7 @@ class LogsTable extends Component {
- {logs.map((l, i) => this.renderTableRow(l, i))} + {logs.map(l => this.renderTableRow(l))}
diff --git a/ui/src/kapacitor/constants/dummyLogs.js b/ui/src/kapacitor/constants/dummyLogs.js deleted file mode 100644 index a94d67b3f0..0000000000 --- a/ui/src/kapacitor/constants/dummyLogs.js +++ /dev/null @@ -1,1323 +0,0 @@ -export const DUMMY_LOGS = [ - { - ts: '2017-10-16T15:36:31.329-04:00', - lvl: 'info', - msg: 'created log session', - service: 'sessions', - id: 'aa87c0b6-26d0-484a-8f15-7445c2d5f386', - 'content-type': 'application/json', - tags: 'nil', - }, - { - ts: '2017-10-16T15:36:31.329-04:00', - lvl: 'error', - msg: '2017/10/16 15:36:31 http: multiple response.WriteHeader calls\n', - service: 'httpd_server_errors', - }, - { - ts: '2017-10-16T15:36:32.090-04:00', - lvl: 'debug', - msg: 'starting next batch query', - service: 'kapacitor', - task_master: 'main', - task: 'batch', - node: 'query1', - query: - "SELECT mean(usage_user) FROM telegraf.autogen.cpu WHERE time >= '2017-10-16T19:35:32.089928906Z' AND time < '2017-10-16T19:36:32.089928906Z'", - }, - { - ts: '2017-10-16T15:36:32.241-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-16T15:36:32.241436147-04:00', - method: 'POST', - uri: '/write?consistency=&db=mydb&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - 'request-id': '502cb71e-b2a9-11e7-8186-000000000000', - duration: '59.135µs', - }, - { - ts: '2017-10-16T15:36:35.313-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-16T15:36:35.312244484-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - 'request-id': '52014892-b2a9-11e7-8187-000000000000', - duration: '1.468473ms', - }, - { - ts: '2017-10-16T15:36:35.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - load15: 1.71, - n_users: 8, - load5: 1.78, - n_cpus: 8, - load1: 1.74, - }, - time: '2017-10-16T19:36:35Z', - }, - { - ts: '2017-10-16T15:36:35.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - uptime_format: '11 days, 2:08', - uptime: 958109, - }, - time: '2017-10-16T19:36:35Z', - }, - { - ts: '2017-10-16T15:36:36.664-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-16T15:36:36.663967463-04:00', - method: 'POST', - uri: '/write?consistency=&db=_internal&precision=ns&rp=monitor', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - 'request-id': '52cf8a43-b2a9-11e7-8188-000000000000', - duration: '624.155µs', - }, - { - ts: '2017-10-16T15:36:40.313-04:00', - lvl: 'warn', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-16T15:36:40.312324709-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - 'request-id': '54fc3c33-b2a9-11e7-8189-000000000000', - duration: '1.0192ms', - }, - { - ts: '2017-10-16T15:36:40.313-04:00', - lvl: 'ok', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - host: 'Michaels-MBP-2.router.edm', - cluster_id: 'michaels-example-cluster', - }, - field: { - load15: 1.71, - n_cpus: 8, - load1: 1.68, - load5: 1.77, - n_users: 8, - }, - time: '2017-10-16T19:36:40Z', - }, - - { - ts: '2017-10-17T14:41:20.882-04:00', - lvl: 'info', - msg: 'created log session', - service: 'sessions', - id: 'fe0be004-4417-4889-a6be-fce3bc56b5f8', - 'content-type': 'application/json', - tags: 'nil', - }, - { - ts: '2017-10-17T14:41:20.882-04:00', - lvl: 'error', - msg: '2017/10/17 14:41:20 http: multiple response.WriteHeader calls\n', - service: 'httpd_server_errors', - }, - { - ts: '2017-10-17T14:41:25.125-04:00', - lvl: 'debug', - msg: 'starting next batch query', - service: 'kapacitor', - task_master: 'main', - task: 'batch', - node: 'query1', - query: - 'SELECT mean(usage_user) FROM telegraf.autogen.cpu WHERE time >= ‘2017-10-17T18:40:25.125253198Z’ AND time < ‘2017-10-17T18:41:25.125253198Z’', - }, - { - ts: '2017-10-17T14:41:25.285-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:25.285657166-04:00', - method: 'POST', - uri: '/write?consistency=&db=mydb&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'c77d0f01-b36a-11e7-966d-000000000000', - duration: '81.785µs', - }, - { - ts: '2017-10-17T14:41:25.312-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:25.310586775-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'c780dcd5-b36a-11e7-966e-000000000000', - duration: '1.898055ms', - }, - { - ts: '2017-10-17T14:41:25.312-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - n_users: 8, - load1: 1.95, - load5: 2.22, - load15: 2.04, - n_cpus: 8, - }, - time: '2017-10-17T18:41:25Z', - }, - { - ts: '2017-10-17T14:41:25.312-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - uptime: 1041199, - uptime_format: '12 days, 1:13', - }, - time: '2017-10-17T18:41:25Z', - }, - { - ts: '2017-10-17T14:41:25.314-04:00', - lvl: 'error', - msg: 'failed to POST data', - service: 'kapacitor', - task_master: 'main', - task: 'httppost', - node: 'http_post3', - err: - 'Post http://localhost:8080/example: dial tcp [::1]:8080: getsockopt: connection refused', - }, - { - ts: '2017-10-17T14:41:30.313-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:30.312728774-04:00', - method: 'POST', - uri: '/write?consistency=&db=_internal&precision=ns&rp=monitor', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'ca7c2100-b36a-11e7-966f-000000000000', - duration: '919.036µs', - }, - { - ts: '2017-10-17T14:41:30.314-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:30.312814501-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'ca7c2454-b36a-11e7-9670-000000000000', - duration: '1.237587ms', - }, - { - ts: '2017-10-17T14:41:30.314-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - n_cpus: 8, - load1: 2.19, - n_users: 8, - load5: 2.26, - load15: 2.05, - }, - time: '2017-10-17T18:41:30Z', - }, - { - ts: '2017-10-17T14:41:30.314-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - uptime: 1041204, - uptime_format: '12 days, 1:13', - }, - time: '2017-10-17T18:41:30Z', - }, - { - ts: '2017-10-17T14:41:35.126-04:00', - lvl: 'debug', - msg: 'starting next batch query', - service: 'kapacitor', - task_master: 'main', - task: 'batch', - node: 'query1', - query: - 'SELECT mean(usage_user) FROM telegraf.autogen.cpu WHERE time >= ‘2017-10-17T18:40:35.125820959Z’ AND time < ‘2017-10-17T18:41:35.125820959Z’', - }, - { - ts: '2017-10-17T14:41:35.284-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:35.284066121-04:00', - method: 'POST', - uri: '/write?consistency=&db=mydb&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'cd72b1da-b36a-11e7-9671-000000000000', - duration: '56.943µs', - }, - { - ts: '2017-10-17T14:41:35.310-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:35.309032877-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'cd76811f-b36a-11e7-9672-000000000000', - duration: '1.262848ms', - }, - { - ts: '2017-10-17T14:41:35.310-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - n_cpus: 8, - load1: 2.1, - load15: 2.05, - n_users: 8, - load5: 2.24, - }, - time: '2017-10-17T18:41:35Z', - }, - { - ts: '2017-10-17T14:41:35.310-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - uptime: 1041209, - uptime_format: '12 days, 1:13', - }, - time: '2017-10-17T18:41:35Z', - }, - { - ts: '2017-10-17T14:41:35.312-04:00', - lvl: 'error', - msg: 'failed to POST data', - service: 'kapacitor', - task_master: 'main', - task: 'httppost', - node: 'http_post3', - err: - 'Post http://localhost:8080/example: dial tcp [::1]:8080: getsockopt: connection refused', - }, - { - ts: '2017-10-17T14:41:40.311-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:40.310966717-04:00', - method: 'POST', - uri: '/write?consistency=&db=_internal&precision=ns&rp=monitor', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'd071bd27-b36a-11e7-9673-000000000000', - duration: '625.873µs', - }, - { - ts: '2017-10-17T14:41:40.313-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:40.312029958-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'd071e6b0-b36a-11e7-9674-000000000000', - duration: '1.021583ms', - }, - { - ts: '2017-10-17T14:41:40.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - load1: 2.01, - load15: 2.04, - n_users: 8, - load5: 2.22, - n_cpus: 8, - }, - time: '2017-10-17T18:41:40Z', - }, - { - ts: '2017-10-17T14:41:40.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - uptime_format: '12 days, 1:13', - uptime: 1041214, - }, - time: '2017-10-17T18:41:40Z', - }, - { - ts: '2017-10-17T14:41:45.029-04:00', - lvl: 'debug', - msg: 'linking subscription for cluster', - service: 'influxdb', - cluster: 'default', - }, - { - ts: '2017-10-17T14:41:45.125-04:00', - lvl: 'debug', - msg: 'starting next batch query', - service: 'kapacitor', - task_master: 'main', - task: 'batch', - node: 'query1', - query: - 'SELECT mean(usage_user) FROM telegraf.autogen.cpu WHERE time >= ‘2017-10-17T18:40:45.125467573Z’ AND time < ‘2017-10-17T18:41:45.125467573Z’', - }, - { - ts: '2017-10-17T14:41:45.284-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:45.284222418-04:00', - method: 'POST', - uri: '/write?consistency=&db=mydb&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'd36898f5-b36a-11e7-9675-000000000000', - duration: '83.559µs', - }, - { - ts: '2017-10-17T14:41:45.310-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:45.309477008-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'd36c7378-b36a-11e7-9676-000000000000', - duration: '1.420439ms', - }, - { - ts: '2017-10-17T14:41:45.311-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - load1: 2.09, - load5: 2.23, - load15: 2.05, - n_users: 8, - n_cpus: 8, - }, - time: '2017-10-17T18:41:45Z', - }, - { - ts: '2017-10-17T14:41:45.311-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - uptime_format: '12 days, 1:13', - uptime: 1041219, - }, - time: '2017-10-17T18:41:45Z', - }, - { - ts: '2017-10-17T14:41:45.312-04:00', - lvl: 'error', - msg: 'failed to POST data', - service: 'kapacitor', - task_master: 'main', - task: 'httppost', - node: 'http_post3', - err: - 'Post http://localhost:8080/example: dial tcp [::1]:8080: getsockopt: connection refused', - }, - { - ts: '2017-10-17T14:41:50.313-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:50.312188999-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'd667cde7-b36a-11e7-9677-000000000000', - duration: '1.16719ms', - }, - { - ts: '2017-10-17T14:41:50.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - n_users: 8, - n_cpus: 8, - load1: 2, - load5: 2.21, - load15: 2.04, - }, - time: '2017-10-17T18:41:50Z', - }, - { - ts: '2017-10-17T14:41:50.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - uptime: 1041224, - uptime_format: '12 days, 1:13', - }, - time: '2017-10-17T18:41:50Z', - }, - { - ts: '2017-10-17T14:41:50.314-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:50.313483319-04:00', - method: 'POST', - uri: '/write?consistency=&db=_internal&precision=ns&rp=monitor', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'd6680077-b36a-11e7-9678-000000000000', - duration: '920µs', - }, - { - ts: '2017-10-17T14:41:55.124-04:00', - lvl: 'debug', - msg: 'starting next batch query', - service: 'kapacitor', - task_master: 'main', - task: 'batch', - node: 'query1', - query: - 'SELECT mean(usage_user) FROM telegraf.autogen.cpu WHERE time >= ‘2017-10-17T18:40:55.124375998Z’ AND time < ‘2017-10-17T18:41:55.124375998Z’', - }, - { - ts: '2017-10-17T14:41:55.286-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:55.286598214-04:00', - method: 'POST', - uri: '/write?consistency=&db=mydb&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'd95ed6c3-b36a-11e7-9679-000000000000', - duration: '74.558µs', - }, - { - ts: '2017-10-17T14:41:55.313-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:41:55.312049056-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'd962b8f0-b36a-11e7-967a-000000000000', - duration: '1.436052ms', - }, - { - ts: '2017-10-17T14:41:55.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - load5: 2.19, - load15: 2.03, - n_cpus: 8, - load1: 1.92, - n_users: 8, - }, - time: '2017-10-17T18:41:55Z', - }, - { - ts: '2017-10-17T14:41:55.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - uptime: 1041229, - uptime_format: '12 days, 1:13', - }, - time: '2017-10-17T18:41:55Z', - }, - { - ts: '2017-10-17T14:41:55.315-04:00', - lvl: 'error', - msg: 'failed to POST data', - service: 'kapacitor', - task_master: 'main', - task: 'httppost', - node: 'http_post3', - err: - 'Post http://localhost:8080/example: dial tcp [::1]:8080: getsockopt: connection refused', - }, - { - ts: '2017-10-17T14:42:00.307-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:42:00.307216928-04:00', - method: 'POST', - uri: '/write?consistency=&db=_internal&precision=ns&rp=monitor', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'dc5cecae-b36a-11e7-967b-000000000000', - duration: '677.414µs', - }, - { - ts: '2017-10-17T14:42:00.313-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:42:00.31193199-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'dc5da4db-b36a-11e7-967c-000000000000', - duration: '1.114033ms', - }, - { - ts: '2017-10-17T14:42:00.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - n_cpus: 8, - load1: 1.85, - load5: 2.17, - n_users: 8, - load15: 2.03, - }, - time: '2017-10-17T18:42:00Z', - }, - { - ts: '2017-10-17T14:42:00.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - uptime: 1041234, - uptime_format: '12 days, 1:13', - }, - time: '2017-10-17T18:42:00Z', - }, - { - ts: '2017-10-17T14:42:05.124-04:00', - lvl: 'debug', - msg: 'starting next batch query', - service: 'kapacitor', - task_master: 'main', - task: 'batch', - node: 'query1', - query: - 'SELECT mean(usage_user) FROM telegraf.autogen.cpu WHERE time >= ‘2017-10-17T18:41:05.124414633Z’ AND time < ‘2017-10-17T18:42:05.124414633Z’', - }, - { - ts: '2017-10-17T14:42:05.283-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:42:05.283540824-04:00', - method: 'POST', - uri: '/write?consistency=&db=mydb&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'df544055-b36a-11e7-967d-000000000000', - duration: '75.496µs', - }, - { - ts: '2017-10-17T14:42:05.312-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:42:05.311360104-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'df587f07-b36a-11e7-967e-000000000000', - duration: '1.255932ms', - }, - { - ts: '2017-10-17T14:42:05.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - host: 'Michaels-MBP-2.router.edm', - cluster_id: 'michaels-example-cluster', - }, - field: { - load1: 1.86, - load15: 2.03, - n_users: 8, - load5: 2.17, - n_cpus: 8, - }, - time: '2017-10-17T18:42:05Z', - }, - { - ts: '2017-10-17T14:42:05.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - uptime: 1041239, - uptime_format: '12 days, 1:13', - }, - time: '2017-10-17T18:42:05Z', - }, - { - ts: '2017-10-17T14:42:05.315-04:00', - lvl: 'error', - msg: 'failed to POST data', - service: 'kapacitor', - task_master: 'main', - task: 'httppost', - node: 'http_post3', - err: - 'Post http://localhost:8080/example: dial tcp [::1]:8080: getsockopt: connection refused', - }, - { - ts: '2017-10-17T14:42:10.313-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:42:10.31170993-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'e2537d30-b36a-11e7-967f-000000000000', - duration: '1.304237ms', - }, - { - ts: '2017-10-17T14:42:10.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - load1: 1.87, - load5: 2.17, - load15: 2.03, - n_users: 8, - n_cpus: 8, - }, - time: '2017-10-17T18:42:10Z', - }, - { - ts: '2017-10-17T14:42:10.313-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - uptime_format: '12 days, 1:14', - uptime: 1041244, - }, - time: '2017-10-17T18:42:10Z', - }, - { - ts: '2017-10-17T14:42:10.314-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:42:10.313200647-04:00', - method: 'POST', - uri: '/write?consistency=&db=_internal&precision=ns&rp=monitor', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'e253b76b-b36a-11e7-9680-000000000000', - duration: '1.030371ms', - }, - { - ts: '2017-10-17T14:42:15.122-04:00', - lvl: 'debug', - msg: 'starting next batch query', - service: 'kapacitor', - task_master: 'main', - task: 'batch', - node: 'query1', - query: - 'SELECT mean(usage_user) FROM telegraf.autogen.cpu WHERE time >= ‘2017-10-17T18:41:15.12194903Z’ AND time < ‘2017-10-17T18:42:15.12194903Z’', - }, - { - ts: '2017-10-17T14:42:15.282-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:42:15.282315534-04:00', - method: 'POST', - uri: '/write?consistency=&db=mydb&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'e549f17a-b36a-11e7-9681-000000000000', - duration: '94.007µs', - }, - { - ts: '2017-10-17T14:42:15.312-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:42:15.310605432-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'e54e428d-b36a-11e7-9682-000000000000', - duration: '1.596389ms', - }, - { - ts: '2017-10-17T14:42:15.312-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - n_cpus: 8, - load1: 2.04, - load5: 2.2, - load15: 2.04, - n_users: 8, - }, - time: '2017-10-17T18:42:15Z', - }, - { - ts: '2017-10-17T14:42:15.312-04:00', - lvl: 'info', - msg: 'point', - service: 'kapacitor', - task_master: 'main', - task: 'log', - node: 'log2', - prefix: '', - name: 'system', - db: 'telegraf', - rp: 'autogen', - group: 'cluster_id=michaels-example-cluster,host=Michaels-MBP-2.router.edm', - dimension_0: 'cluster_id', - dimension_1: 'host', - tag: { - cluster_id: 'michaels-example-cluster', - host: 'Michaels-MBP-2.router.edm', - }, - field: { - uptime: 1041249, - uptime_format: '12 days, 1:14', - }, - time: '2017-10-17T18:42:15Z', - }, - { - ts: '2017-10-17T14:42:15.314-04:00', - lvl: 'error', - msg: 'failed to POST data', - service: 'kapacitor', - task_master: 'main', - task: 'httppost', - node: 'http_post3', - err: - 'Post http://localhost:8080/example: dial tcp [::1]:8080: getsockopt: connection refused', - }, - { - ts: '2017-10-17T14:42:20.311-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:42:20.311150281-04:00', - method: 'POST', - uri: '/write?consistency=&db=_internal&precision=ns&rp=monitor', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'e8494853-b36a-11e7-9683-000000000000', - duration: '711.257µs', - }, - { - ts: '2017-10-17T14:42:20.313-04:00', - lvl: 'info', - msg: 'http request', - service: 'http', - host: '::1', - username: '-', - start: '2017-10-17T14:42:20.312349859-04:00', - method: 'POST', - uri: '/write?consistency=&db=telegraf&precision=ns&rp=autogen', - protocol: 'HTTP/1.1', - status: 204, - referer: '-', - user_agent: 'InfluxDBClient', - request_id: 'e849772e-b36a-11e7-9684-000000000000', - duration: '1.079043ms', - }, -] diff --git a/ui/src/kapacitor/containers/TickscriptPage.js b/ui/src/kapacitor/containers/TickscriptPage.js index bbafe7f1b3..07d6386201 100644 --- a/ui/src/kapacitor/containers/TickscriptPage.js +++ b/ui/src/kapacitor/containers/TickscriptPage.js @@ -1,11 +1,14 @@ import React, {PropTypes, Component} from 'react' import {connect} from 'react-redux' import {bindActionCreators} from 'redux' +import uuid from 'node-uuid' import Tickscript from 'src/kapacitor/components/Tickscript' import * as kapactiorActionCreators from 'src/kapacitor/actions/view' import * as errorActionCreators from 'shared/actions/errors' import {getActiveKapacitor} from 'src/shared/apis' +import {getLogStreamByRuleID} from 'src/kapacitor/apis' +import {publishNotification} from 'shared/actions/notifications' class TickscriptPage extends Component { constructor(props) { @@ -29,26 +32,16 @@ class TickscriptPage extends Component { shouldFetch = null - logKey = j => (log, i) => ({ - ...log, - key: `${log.ts}-${j}-${i}`, - }) - fetchChunkedLogs = async (kapacitor, ruleID) => { + const {notify} = this.props + try { - const response = await fetch( - `${kapacitor.links.proxy}?path=/kapacitor/v1/logs?task=${ruleID}`, - { - method: 'GET', - headers: {'Content-Type': 'application/json'}, - } - ) + const response = await getLogStreamByRuleID(kapacitor, ruleID) const reader = await response.body.getReader() const decoder = new TextDecoder() let result - let j = 0 while (this.shouldFetch === true && !(result && result.done)) { result = await reader.read() @@ -57,20 +50,21 @@ class TickscriptPage extends Component { stream: !result.done, }) - const json = `[${chunk.split('}{').join('},{')}]` + const json = `[${chunk.split('}\n{').join('},{')}]` - const logs = JSON.parse(json).map(this.logKey(j)) + const logs = JSON.parse(json).map(log => ({ + ...log, + key: uuid.v4(), + })) this.setState({ - logs: [...this.state.logs, ...logs], + logs: [...logs, ...this.state.logs], }) - - j += 1 } } catch (error) { console.error(error) + notify('error', error) throw error - // TODO error handling } } @@ -205,6 +199,7 @@ TickscriptPage.propTypes = { ruleID: string, }).isRequired, rules: arrayOf(shape()), + notify: func.isRequired, } const mapStateToProps = state => { @@ -216,6 +211,7 @@ const mapStateToProps = state => { const mapDispatchToProps = dispatch => ({ kapacitorActions: bindActionCreators(kapactiorActionCreators, dispatch), errorActions: bindActionCreators(errorActionCreators, dispatch), + notify: bindActionCreators(publishNotification, dispatch), }) export default connect(mapStateToProps, mapDispatchToProps)(TickscriptPage) diff --git a/ui/src/shared/components/ResizeContainer.js b/ui/src/shared/components/ResizeContainer.js index 07fd59417d..a67a40374b 100644 --- a/ui/src/shared/components/ResizeContainer.js +++ b/ui/src/shared/components/ResizeContainer.js @@ -97,7 +97,7 @@ class ResizeContainer extends Component { render() { const {bottomHeightPixels, topHeight, bottomHeight, isDragging} = this.state - const {containerClass, children, isKapacitorTheme} = this.props + const {containerClass, children, theme} = this.props if (React.Children.count(children) > maximumNumChildren) { console.error( @@ -122,7 +122,7 @@ class ResizeContainer extends Component { })}