Skip to content

Commit 26433c1

Browse files
author
Richard
authored
Merge pull request #25 from squaredup/work/rp/sumo-logic
Add Sumo Logic
2 parents 4d35964 + 5a0090d commit 26433c1

6 files changed

Lines changed: 259 additions & 0 deletions

File tree

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"name": "metricsQuery",
3+
"displayName": "Metrics Query",
4+
"description": "Execute a metrics query returning time series data",
5+
"baseDataSourceName": "httpRequestUnscoped",
6+
"manualConfigApply": true,
7+
"config": {
8+
"httpMethod": "post",
9+
"paging": {
10+
"mode": "none"
11+
},
12+
"expandInnerObjects": true,
13+
"endpointPath": "v1/metricsQueries",
14+
"getArgs": [],
15+
"headers": [],
16+
"postBody": {
17+
"queries": [{
18+
"rowId": "A",
19+
"query": "{{metricQuery}}",
20+
"quantization": "{{ typeof quantization !== 'undefined' && quantization ? Number(quantization) : undefined }}",
21+
"rollup": "{{ typeof rollup !== 'undefined' && rollup ? rollup : undefined }}",
22+
"timeshift": "{{ typeof timeshift !== 'undefined' && timeshift ? Number(timeshift) : undefined }}"
23+
}],
24+
"timeRange": {
25+
"type": "BeginBoundedTimeRange",
26+
"from": {
27+
"type": "Iso8601TimeRangeBoundary",
28+
"iso8601Time": "{{timeframe.start}}"
29+
},
30+
"to": {
31+
"type": "Iso8601TimeRangeBoundary",
32+
"iso8601Time": "{{timeframe.end}}"
33+
}
34+
}
35+
},
36+
"postRequestScript": "queryFlattener.js"
37+
},
38+
"timeframes": true,
39+
"ui": [
40+
{
41+
"name": "metricQuery",
42+
"label": "Metric query",
43+
"placeholder": "metric=CPU_Idle",
44+
"type": "text",
45+
"validation": {
46+
"required": true,
47+
"maxLength": 3000
48+
}
49+
},
50+
{
51+
"name": "quantization",
52+
"label": "Quantization",
53+
"placeholder": "60000",
54+
"help": "Segregates time series data by time period. This allows you to create aggregated results in buckets of fixed intervals (for example, 5-minute intervals). The value is in milliseconds.",
55+
"type": "number",
56+
"validation": {
57+
"required": false,
58+
"min": 1
59+
}
60+
},
61+
{
62+
"isMulti": false,
63+
"data": {
64+
"source": "fixed",
65+
"values": [
66+
{
67+
"value": "Avg",
68+
"label": "Avg"
69+
},
70+
{
71+
"value": "Sum",
72+
"label": "Sum"
73+
},
74+
{
75+
"value": "Min",
76+
"label": "Min"
77+
},
78+
{
79+
"value": "Max",
80+
"label": "Max"
81+
},
82+
{
83+
"value": "Count",
84+
"label": "Count"
85+
},
86+
{
87+
"value": "None",
88+
"label": "None"
89+
}
90+
]
91+
},
92+
"name": "rollup",
93+
"label": "Rollup",
94+
"placeholder": "Select rollup",
95+
"type": "autocomplete",
96+
"allowCustomValues": false
97+
},
98+
{
99+
"name": "timeshift",
100+
"label": "Timeshift",
101+
"placeholder": "-3600000",
102+
"type": "number",
103+
"help": "Shifts the time series from your metrics query by the specified amount of time. This can help when comparing a time series across multiple time periods. Specified as a signed duration in milliseconds.",
104+
"validation": {
105+
"max": 0,
106+
"required": false
107+
}
108+
}
109+
],
110+
"metadata": [
111+
{
112+
"shape": [
113+
"date",
114+
{
115+
"timeZone": "Etc/UTC"
116+
}
117+
],
118+
"name": "timestamp"
119+
},
120+
{
121+
"pattern": ".*"
122+
}
123+
]
124+
}
125+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const { queryResult: [queryResultBody] = [], errors } = data;
2+
3+
if (errors?.errors?.length && !queryResultBody?.timeSeriesList?.timeSeries?.length) {
4+
throw new Error(errors.errors.map(({ message }) => message).join(', '));
5+
}
6+
7+
if (queryResultBody?.timeSeriesList?.timeSeries?.length) {
8+
const timeseriesResults = queryResultBody.timeSeriesList.timeSeries;
9+
10+
result = timeseriesResults.flatMap(({ metricDefinition, points }) =>
11+
points.timestamps.map((timestamp, index) => ({
12+
value: points.values[index],
13+
timestamp,
14+
unit: queryResultBody.timeSeriesList.unit,
15+
...metricDefinition
16+
}))
17+
)
18+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Setup
2+
3+
Authentication is via Personal Access Key.
4+
5+
Create a Personal Access Key in [https://service.sumologic.com/personal-access-keys](https://service.sumologic.com/personal-access-keys) (replace the subdomain with the deployment region of your account; see the [Sumo Logic documentation](https://www.sumologic.com/help/docs/api/access-keys/) for more information)

plugins/SumoLogic/v1/icon.png

15.7 KB
Loading

plugins/SumoLogic/v1/metadata.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "sumo-logic",
3+
"displayName": "Sumo Logic",
4+
"version": "1.0.0",
5+
"author": {
6+
"name": "@richpeters",
7+
"type": "community"
8+
},
9+
"description": "Query metrics from your Sumo Logic account.",
10+
"category": "Monitoring",
11+
"type": "cloud",
12+
"schemaVersion": "2.0",
13+
"base": {
14+
"plugin": "WebAPI",
15+
"majorVersion": "1",
16+
"config": {
17+
"authMode": "basic",
18+
"queryArgs": [],
19+
"headers": [],
20+
"baseUrl": "{{region}}",
21+
"basicAuthUsername": "{{accessId}}",
22+
"basicAuthPassword": "{{accessKey}}"
23+
}
24+
},
25+
"links": [
26+
{
27+
"category": "documentation",
28+
"url": "https://github.com/squaredup/plugins/blob/main/plugins/SumoLogic/v1/docs/README.md",
29+
"label": "Help adding this plugin"
30+
},
31+
{
32+
"category": "source",
33+
"url": "https://github.com/squaredup/plugins/tree/main/plugins/SumoLogic/v1",
34+
"label": "Repository"
35+
}
36+
]
37+
}

plugins/SumoLogic/v1/ui.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[
2+
{
3+
"type": "text",
4+
"name": "accessId",
5+
"label": "Access ID",
6+
"placeholder": "Enter the Sumo Logic access ID",
7+
"help": "To create an access key visit [https://www.sumologic.com/help/docs/manage/security/access-keys/#create-an-access-key](https://www.sumologic.com/help/docs/manage/security/access-keys/#create-an-access-key)",
8+
"validation": {
9+
"required": true
10+
}
11+
},
12+
{
13+
"type": "password",
14+
"name": "accessKey",
15+
"label": "Access key",
16+
"placeholder": "Enter the Sumo Logic access key",
17+
"validation": {
18+
"required": true
19+
}
20+
},
21+
{
22+
"type": "autocomplete",
23+
"name": "region",
24+
"help": "Determine the region based on the target account's deployment pod, [learn more](https://www.sumologic.com/help/docs/api/about-apis/getting-started/#which-endpoint-should-i-should-use)",
25+
"label": "Region",
26+
"allowCustomValues": false,
27+
"defaultValue": "https://api.sumologic.com/api/",
28+
"isMulti": false,
29+
"validation": {
30+
"required": true
31+
},
32+
"data": {
33+
"source": "fixed",
34+
"values": [
35+
{
36+
"value": "https://api.au.sumologic.com/api/",
37+
"label": "AU"
38+
},
39+
{
40+
"value": "https://api.ca.sumologic.com/api/",
41+
"label": "CA"
42+
},
43+
{
44+
"value": "https://api.de.sumologic.com/api/",
45+
"label": "DE"
46+
},
47+
{
48+
"value": "https://api.eu.sumologic.com/api/",
49+
"label": "EU"
50+
},
51+
{
52+
"value": "https://api.fed.sumologic.com/api/",
53+
"label": "FED"
54+
},
55+
{
56+
"value": "https://api.jp.sumologic.com/api/",
57+
"label": "JP"
58+
},
59+
{
60+
"value": "https://api.kr.sumologic.com/api/",
61+
"label": "KR"
62+
},
63+
{
64+
"value": "https://api.sumologic.com/api/",
65+
"label": "US1"
66+
},
67+
{
68+
"value": "https://api.us2.sumologic.com/api/",
69+
"label": "US2"
70+
}
71+
]
72+
}
73+
}
74+
]

0 commit comments

Comments
 (0)