@jupiterone/jupiterone-mcp 0.0.3 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +2 -2
  2. package/dist/client/graphql/mutations.js +13 -10
  3. package/dist/client/graphql/mutations.js.map +1 -1
  4. package/dist/client/graphql/queries.d.ts +1 -1
  5. package/dist/client/graphql/queries.d.ts.map +1 -1
  6. package/dist/client/graphql/queries.js +22 -19
  7. package/dist/client/graphql/queries.js.map +1 -1
  8. package/dist/client/jupiterone-client.d.ts +3 -1
  9. package/dist/client/jupiterone-client.d.ts.map +1 -1
  10. package/dist/client/jupiterone-client.js +33 -20
  11. package/dist/client/jupiterone-client.js.map +1 -1
  12. package/dist/client/services/account-service.js +8 -4
  13. package/dist/client/services/account-service.js.map +1 -1
  14. package/dist/client/services/alert-service.js +7 -3
  15. package/dist/client/services/alert-service.js.map +1 -1
  16. package/dist/client/services/dashboard-service.js +12 -8
  17. package/dist/client/services/dashboard-service.js.map +1 -1
  18. package/dist/client/services/integration-service.js +11 -7
  19. package/dist/client/services/integration-service.js.map +1 -1
  20. package/dist/client/services/j1ql-service.d.ts.map +1 -1
  21. package/dist/client/services/j1ql-service.js +42 -7
  22. package/dist/client/services/j1ql-service.js.map +1 -1
  23. package/dist/client/services/rule-service.js +17 -13
  24. package/dist/client/services/rule-service.js.map +1 -1
  25. package/dist/generated/description-map.d.ts +2 -0
  26. package/dist/generated/description-map.d.ts.map +1 -0
  27. package/dist/generated/description-map.js +2107 -0
  28. package/dist/generated/description-map.js.map +1 -0
  29. package/dist/index.js +11 -12
  30. package/dist/index.js.map +1 -1
  31. package/dist/server/mcp-server.d.ts +9 -1
  32. package/dist/server/mcp-server.d.ts.map +1 -1
  33. package/dist/server/mcp-server.js +1557 -1360
  34. package/dist/server/mcp-server.js.map +1 -1
  35. package/dist/types/jupiterone.d.ts +3 -2
  36. package/dist/types/jupiterone.d.ts.map +1 -1
  37. package/dist/types/jupiterone.js +2 -1
  38. package/dist/utils/description-loader.js +8 -5
  39. package/dist/utils/description-loader.js.map +1 -1
  40. package/dist/utils/j1ql-validator.d.ts +34 -0
  41. package/dist/utils/j1ql-validator.d.ts.map +1 -0
  42. package/dist/utils/j1ql-validator.js +292 -0
  43. package/dist/utils/j1ql-validator.js.map +1 -0
  44. package/dist/utils/load-description.d.ts.map +1 -1
  45. package/dist/utils/load-description.js +7 -7
  46. package/dist/utils/load-description.js.map +1 -1
  47. package/package.json +5 -5
  48. package/dist/descriptions/create-dashboard-widget.md +0 -325
  49. package/dist/descriptions/create-dashboard.md +0 -12
  50. package/dist/descriptions/create-inline-question-rule.md +0 -374
  51. package/dist/descriptions/create-j1ql-from-natural-language.md +0 -7
  52. package/dist/descriptions/execute-j1ql-query.md +0 -426
  53. package/dist/descriptions/get-integration-definitions.md +0 -27
  54. package/dist/descriptions/get-integration-instances.md +0 -35
  55. package/dist/descriptions/list-alerts.md +0 -14
  56. package/dist/descriptions/list-rules.md +0 -53
  57. package/dist/descriptions/update-dashboard.md +0 -467
  58. package/dist/descriptions/update-inline-question-rule.md +0 -363
@@ -0,0 +1,292 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.J1QLValidator = void 0;
4
+ class J1QLValidator {
5
+ j1qlService;
6
+ constructor(j1qlService) {
7
+ this.j1qlService = j1qlService;
8
+ }
9
+ /**
10
+ * Validates a J1QL query by executing it with a small limit
11
+ * Returns validation result with error details and suggestions
12
+ */
13
+ async validateQuery(query) {
14
+ try {
15
+ // Add a small limit if not present to avoid large result sets during validation
16
+ let validationQuery = query.trim();
17
+ if (!validationQuery.match(/\bLIMIT\s+\d+/i)) {
18
+ validationQuery += ' LIMIT 5';
19
+ }
20
+ const result = await this.j1qlService.executeJ1qlQuery({
21
+ query: validationQuery,
22
+ });
23
+ // Check if we got valid results
24
+ if (result && result.data) {
25
+ return {
26
+ isValid: true,
27
+ results: result,
28
+ };
29
+ }
30
+ return {
31
+ isValid: false,
32
+ error: 'Query returned no data',
33
+ suggestion: 'Verify that entities matching your criteria exist. Try removing filters or using broader entity classes.',
34
+ };
35
+ }
36
+ catch (error) {
37
+ return this.handleQueryError(error, query);
38
+ }
39
+ }
40
+ /**
41
+ * Provides detailed error handling with suggestions
42
+ */
43
+ handleQueryError(error, query) {
44
+ const errorMessage = error?.message || error?.toString() || 'Unknown error';
45
+ // Check specific error patterns first
46
+ for (const { pattern, suggestion } of this.getErrorPatterns()) {
47
+ const match = errorMessage.match(pattern);
48
+ if (match) {
49
+ const suggestionText = typeof suggestion === 'function'
50
+ ? suggestion(match)
51
+ : suggestion === 'syntax_analysis'
52
+ ? this.analyzeSyntaxError(query, errorMessage)
53
+ : suggestion;
54
+ return {
55
+ isValid: false,
56
+ error: errorMessage,
57
+ suggestion: suggestionText,
58
+ };
59
+ }
60
+ }
61
+ return {
62
+ isValid: false,
63
+ error: errorMessage,
64
+ suggestion: this.getGenericSuggestions(query),
65
+ };
66
+ }
67
+ /**
68
+ * Consolidated error patterns for better maintainability
69
+ */
70
+ getErrorPatterns() {
71
+ return [
72
+ // New queryV2 error patterns
73
+ {
74
+ pattern: /Error parsing query\. Unexpected token "(\w+)" at line \d+ column \d+/i,
75
+ suggestion: (match) => {
76
+ const token = match[1].toLowerCase();
77
+ // Check for reserved keywords used as aliases
78
+ const reservedKeywords = [
79
+ 'count',
80
+ 'sum',
81
+ 'avg',
82
+ 'min',
83
+ 'max',
84
+ 'find',
85
+ 'that',
86
+ 'with',
87
+ 'where',
88
+ 'return',
89
+ 'order',
90
+ 'by',
91
+ 'limit',
92
+ 'skip',
93
+ 'has',
94
+ 'relates',
95
+ 'to',
96
+ 'from',
97
+ 'and',
98
+ 'or',
99
+ 'not',
100
+ 'true',
101
+ 'false',
102
+ 'null',
103
+ 'undefined',
104
+ 'as',
105
+ ];
106
+ if (reservedKeywords.includes(token)) {
107
+ return `Cannot use reserved keyword "${token}" as an alias. Choose a different name.`;
108
+ }
109
+ // Check for unquoted string values
110
+ if (match[0].includes('WITH') && match[0].includes('=')) {
111
+ return `String values must be quoted: ${token} should be '${token}'`;
112
+ }
113
+ return 'syntax_analysis'; // Fall back to syntax analysis
114
+ },
115
+ },
116
+ {
117
+ pattern: /Error parsing query\. Unexpected token "(>>|<<)" at line \d+ column \d+/i,
118
+ suggestion: 'Direction arrows must follow the relationship verb: "THAT HAS >>" not "THAT >>"',
119
+ },
120
+ {
121
+ pattern: /Error parsing query\. Unexpected token ">" at line \d+ column \d+.*=>/i,
122
+ suggestion: 'Invalid operator "=>". Use ">=" for greater than or equal',
123
+ },
124
+ {
125
+ pattern: /Error parsing query\. Unexpected token "-" at line \d+ column \d+.*LIMIT/i,
126
+ suggestion: 'SKIP and LIMIT values must be positive numbers',
127
+ },
128
+ {
129
+ pattern: /Error parsing query\. Unexpected token "WITH" at line \d+ column \d+\. Did you mean "with"\?/i,
130
+ suggestion: 'Place alias after WITH: "WITH property = value AS alias"',
131
+ },
132
+ // Existing patterns that still work with queryV2
133
+ {
134
+ pattern: /Invalid return selector provided: "(\w+)", valid return selectors are: "([^"]+)"/i,
135
+ suggestion: (match) => `Undefined alias "${match[1]}". Use "${match[2]}" or define alias: FIND ${match[2]} AS ${match[1]}`,
136
+ },
137
+ {
138
+ pattern: /Invalid predicate filter selector provided: "(\w+)", valid predicate selectors are: "([^"]+)"/i,
139
+ suggestion: (match) => `Undefined alias "${match[1]}" in WHERE clause. Aliases in WHERE must be defined earlier. Valid selectors: ${match[2]}`,
140
+ },
141
+ {
142
+ pattern: /"limit" must be a value between \d+ and \d+/i,
143
+ suggestion: 'LIMIT must be between 1 and 250. Try using COUNT for aggregation queries.',
144
+ },
145
+ // Legacy patterns (keeping for backward compatibility)
146
+ {
147
+ pattern: /J1QL Query is invalid\. Please check the syntax/i,
148
+ suggestion: 'syntax_analysis', // Special marker for syntax analysis
149
+ },
150
+ {
151
+ pattern: /exceeds maximum allowed tokens/i,
152
+ suggestion: 'Query returned too much data. Add LIMIT clause to reduce result size (e.g., LIMIT 100)',
153
+ },
154
+ {
155
+ pattern: /Invalid entity type or class/i,
156
+ suggestion: 'Check entity class capitalization (e.g., User not user) and type format (e.g., aws_iam_user).',
157
+ },
158
+ {
159
+ pattern: /Unknown property/i,
160
+ suggestion: 'Property does not exist. Run discovery: FIND <EntityClass> AS e RETURN e.* LIMIT 10',
161
+ },
162
+ {
163
+ pattern: /Invalid comparison operator/i,
164
+ suggestion: 'Use valid operators: =, !=, ~=, ^=, $=, !~=, !^=, !$=, >, <, >=, <=',
165
+ },
166
+ {
167
+ pattern: /timeout|timed out/i,
168
+ suggestion: 'Query took too long. Add LIMIT clause or simplify the query.',
169
+ },
170
+ ];
171
+ }
172
+ /**
173
+ * Analyzes generic "J1QL Query is invalid" errors for specific issues
174
+ */
175
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
176
+ analyzeSyntaxError(query, _errorMessage) {
177
+ const syntaxChecks = [
178
+ {
179
+ pattern: /"/,
180
+ message: 'Use single quotes for strings, not double quotes',
181
+ },
182
+ {
183
+ pattern: /=\s*([a-zA-Z]+)(?:\s|$)/,
184
+ message: (match) => {
185
+ const value = match[1];
186
+ if (!['true', 'false', 'null', 'undefined'].includes(value)) {
187
+ return `String values must be quoted: ${value} should be '${value}'`;
188
+ }
189
+ return null;
190
+ },
191
+ },
192
+ {
193
+ pattern: /\bAS\s+\w+\s+WITH\b/i,
194
+ message: 'Place alias after WITH: "WITH property = value AS alias"',
195
+ },
196
+ {
197
+ pattern: /\bWHERE\b/i,
198
+ message: query.match(/\bAS\s+\w+.*WHERE/i)
199
+ ? null
200
+ : 'WHERE clause requires aliases. Use "FIND Entity AS e WHERE e.property = value"',
201
+ },
202
+ {
203
+ pattern: /=>/,
204
+ message: 'Invalid operator "=>". Use ">=" for greater than or equal',
205
+ },
206
+ {
207
+ pattern: /THAT\s*>>/i,
208
+ message: 'Direction arrows must follow the relationship verb: "THAT HAS >>" not "THAT >>"',
209
+ },
210
+ {
211
+ pattern: /FIND\s+([a-z]\w*)/,
212
+ message: (match) => {
213
+ const entityClass = match[1];
214
+ if (!entityClass.includes('_')) {
215
+ return `Entity classes should be capitalized: "${entityClass}" should be "${entityClass.charAt(0).toUpperCase() + entityClass.slice(1)}"`;
216
+ }
217
+ return null;
218
+ },
219
+ },
220
+ {
221
+ pattern: /=\s*(yes|no|YES|NO)\b/,
222
+ message: 'Use "true" or "false" for boolean values, not "yes"/"no"',
223
+ },
224
+ {
225
+ pattern: /^(?!.*\bLIMIT\s+\d+)(?!.*\bCOUNT\s*\()/i,
226
+ message: query.match(/\bLIMIT\s+\d+/i) || query.match(/\bCOUNT\s*\(/i)
227
+ ? null
228
+ : 'Add LIMIT clause to prevent query timeout',
229
+ },
230
+ {
231
+ pattern: /=\s*\/[^/]*$/,
232
+ message: 'Invalid regex pattern - missing closing slash',
233
+ },
234
+ {
235
+ pattern: /\b(SKIP|LIMIT)\s+-\d+/i,
236
+ message: 'SKIP and LIMIT values must be positive numbers',
237
+ },
238
+ {
239
+ pattern: /\bLIMIT\s+0\b/i,
240
+ message: 'LIMIT must be at least 1',
241
+ },
242
+ {
243
+ pattern: /\bAS\s+(count|sum|avg|min|max|find|that|with|where|return|order|by|limit|skip|has|relates|to|from|and|or|not|true|false|null|undefined|as)\b/i,
244
+ message: (match) => {
245
+ const keyword = match[1];
246
+ return `Cannot use reserved keyword "${keyword}" as an alias. Choose a different name.`;
247
+ },
248
+ },
249
+ ];
250
+ const issues = syntaxChecks
251
+ .map((check) => {
252
+ const match = query.match(check.pattern);
253
+ if (match) {
254
+ return typeof check.message === 'function' ? check.message(match) : check.message;
255
+ }
256
+ return null;
257
+ })
258
+ .filter(Boolean);
259
+ return issues.length > 0 ? issues.join('\n') : this.getGenericSuggestions(query);
260
+ }
261
+ /**
262
+ * Provides generic suggestions based on query structure
263
+ */
264
+ getGenericSuggestions(query) {
265
+ const commonIssues = [
266
+ {
267
+ check: () => !query.match(/\bLIMIT\s+\d+/i) && !query.match(/\bCOUNT\s*\(/i),
268
+ message: 'Add LIMIT clause to prevent large result sets',
269
+ },
270
+ {
271
+ check: () => query.match(/\bWHERE\b/i) && !query.match(/\bAS\s+\w+.*WHERE/i),
272
+ message: 'WHERE clause requires aliases. Use "FIND Entity AS e WHERE e.property = value"',
273
+ },
274
+ {
275
+ check: () => query.includes('"'),
276
+ message: 'Use single quotes for strings, not double quotes',
277
+ },
278
+ {
279
+ check: () => query.match(/\bAS\s+\w+\s+WITH\b/i),
280
+ message: 'Place alias after WITH: "WITH property = value AS alias"',
281
+ },
282
+ { check: () => !query.match(/\b(FIND|find)\b/), message: 'Query must start with FIND' },
283
+ ];
284
+ const suggestions = commonIssues.filter((issue) => issue.check()).map((issue) => issue.message);
285
+ if (suggestions.length === 0) {
286
+ suggestions.push('Try these discovery queries first:', '1. FIND * AS e RETURN e._class, COUNT(e) - to see available entity classes', '2. FIND <EntityClass> AS e RETURN e.* LIMIT 10 - to see entity properties', '3. FIND Entity1 THAT RELATES TO AS rel Entity2 RETURN rel._class - to discover relationships');
287
+ }
288
+ return suggestions.join('\n');
289
+ }
290
+ }
291
+ exports.J1QLValidator = J1QLValidator;
292
+ //# sourceMappingURL=j1ql-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"j1ql-validator.js","sourceRoot":"","sources":["../../src/utils/j1ql-validator.ts"],"names":[],"mappings":";;;AASA,MAAa,aAAa;IACJ;IAApB,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEhD;;;OAGG;IACH,KAAK,CAAC,aAAa,CAAC,KAAa;QAC/B,IAAI,CAAC;YACH,gFAAgF;YAChF,IAAI,eAAe,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;YACnC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC;gBAC7C,eAAe,IAAI,UAAU,CAAC;YAChC,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC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;YACD;gBACE,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC;gBAC5E,OAAO,EAAE,gFAAgF;aAC1F;YACD;gBACE,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAChC,OAAO,EAAE,kDAAkD;aAC5D;YACD;gBACE,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,sBAAsB,CAAC;gBAChD,OAAO,EAAE,0DAA0D;aACpE;YACD,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,4BAA4B,EAAE;SACxF,CAAC;QAEF,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEhG,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,WAAW,CAAC,IAAI,CACd,oCAAoC,EACpC,4EAA4E,EAC5E,2EAA2E,EAC3E,8FAA8F,CAC/F,CAAC;QACJ,CAAC;QAED,OAAO,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACF;AA5TD,sCA4TC"}
@@ -1 +1 @@
1
- {"version":3,"file":"load-description.d.ts","sourceRoot":"","sources":["../../src/utils/load-description.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGxD"}
1
+ {"version":3,"file":"load-description.d.ts","sourceRoot":"","sources":["../../src/utils/load-description.ts"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAExD"}
@@ -1,9 +1,9 @@
1
- import { readFileSync } from 'fs';
2
- import { join } from 'path';
3
- import { fileURLToPath } from 'url';
4
- const __dirname = fileURLToPath(new URL('.', import.meta.url));
5
- export function loadDescription(filename) {
6
- const filePath = join(__dirname, '..', 'descriptions', filename);
7
- return readFileSync(filePath, 'utf-8');
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadDescription = loadDescription;
4
+ // src/utils/load-description.ts
5
+ const description_map_js_1 = require("../generated/description-map.js");
6
+ function loadDescription(filename) {
7
+ return description_map_js_1.descriptionMap[filename] ?? '';
8
8
  }
9
9
  //# sourceMappingURL=load-description.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"load-description.js","sourceRoot":"","sources":["../../src/utils/load-description.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,SAAS,GAAG,aAAa,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;IACjE,OAAO,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC"}
1
+ {"version":3,"file":"load-description.js","sourceRoot":"","sources":["../../src/utils/load-description.ts"],"names":[],"mappings":";;AAGA,0CAEC;AALD,gCAAgC;AAChC,wEAAiE;AAEjE,SAAgB,eAAe,CAAC,QAAgB;IAC9C,OAAO,mCAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AACxC,CAAC"}
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@jupiterone/jupiterone-mcp",
3
- "version": "0.0.3",
3
+ "version": "0.0.6",
4
4
  "description": "Model Context Protocol server for JupiterOne account rules and rule details",
5
- "type": "module",
6
5
  "main": "dist/index.js",
7
6
  "bin": {
8
7
  "jupiterone-mcp": "dist/index.js"
9
8
  },
10
9
  "scripts": {
11
- "build": "tsc && npm run copy-descriptions",
12
- "copy-descriptions": "cp -r src/descriptions dist/",
13
- "dev": "npm run build && npx nodemon --watch src --ext ts --exec 'npm run build && npx dotenv -e .env -- npx @modelcontextprotocol/inspector node dist/index.js'",
10
+ "prebuild": "npx tsx scripts/generate-descriptions.ts",
11
+ "build": "npm run prebuild && tsc",
12
+ "dev": "npm run build && npx nodemon --watch src --ext ts --ignore src/generated --exec 'npm run build'",
13
+ "inspector": "npx dotenv -e .env -- npx @modelcontextprotocol/inspector node dist/index.js",
14
14
  "start": "node dist/index.js",
15
15
  "test": "jest",
16
16
  "test-connection": "node test-connection.js",
@@ -1,325 +0,0 @@
1
- # JupiterOne Create Dashboard Widget Tool
2
-
3
- **Purpose**: Adds a new widget to a specified JupiterOne dashboard. This tool allows you to programmatically create visual widgets (such as pie charts, bar charts, tables, etc.) on any dashboard, using custom queries and configuration.
4
-
5
- This tool should be used when:
6
- - You want to add a new visualization to an existing dashboard
7
- - You need to automate dashboard widget creation for reporting or monitoring
8
- - You want to programmatically manage dashboard content
9
-
10
- ## Required Parameters
11
- - `dashboardId`: The ID of the dashboard to add the widget to
12
- - `input`: The widget configuration object (CreateInsightsWidgetInput), including:
13
- - `title`: Widget title
14
- - `description`: Widget description (optional)
15
- - `type`: Widget type (e.g., 'pie', 'bar', 'table', etc.)
16
- - `noResultMessage`: Message to display when there are no results
17
- - `config`: Widget configuration, including queries and settings
18
-
19
- ## Supported Chart Types
20
-
21
- The following values are supported for the `type` property when creating a widget:
22
-
23
- ```typescript
24
- export enum ChartType {
25
- Area = 'area',
26
- Bar = 'bar',
27
- Graph = 'graph',
28
- Line = 'line',
29
- Matrix = 'matrix',
30
- Number = 'number',
31
- Pie = 'pie',
32
- Table = 'table',
33
- Status = 'status',
34
- Markdown = 'markdown',
35
- }
36
- ```
37
-
38
- ## Example Usage
39
- ```json
40
- {
41
- "dashboardId": "95936c1a-468a-494f-b11d-b134ac9b9577",
42
- "input": {
43
- "title": "Example title",
44
- "type": "pie",
45
- "noResultMessage": "Message that shows when no results",
46
- "config": {
47
- "queries": [
48
- {
49
- "query": "FIND (aws_db_cluster_snapshot|aws_db_snapshot) as snapshot\n RETURN\n snapshot.tag.AccountName as name,\n sum(snapshot.allocatedStorage) * 0.02 as value",
50
- "name": "Query 1"
51
- }
52
- ],
53
- "settings": {
54
- "pie": {
55
- "customColors": {
56
- "0": "#26A69A",
57
- "1": "#3F51B5",
58
- "2": "#D81B60",
59
- "3": "#FF8F00",
60
- "4": "#9575CD",
61
- "5": "#8BC34A",
62
- "6": "#039BE5"
63
- },
64
- "upwardTrendIsGood": true
65
- }
66
- }
67
- }
68
- }
69
- }
70
- ```
71
-
72
- # Widget Options
73
-
74
- When creating a dashboard, there are several options for widgets to choose from. This allows you to utilize the most impactful visual representation for your data. Below are the supported dashboard widgets, each with their own requirements and examples.
75
-
76
- ---
77
-
78
- # Chart Types and Example Queries
79
-
80
- > **Note:**
81
- > To enable trend functionality for a chart, set `trendDataIsEnabled: true` in the relevant chart type's settings (e.g., `settings.pie.trendDataIsEnabled`). You can also use keys like `trendQueryResultsCount` to control the number of trend data points, and `upwardTrendIsGood` to indicate if an upward trend is positive.
82
-
83
- ## Number
84
- The number chart visualization shows one large stat value. In the trend version of this chart you are able to track the value through a spark line to see if the result is getting larger or smaller over time.
85
-
86
- ### Query Requirements
87
- Expects only a single `value` in the returned query response.
88
-
89
- ### Example Queries
90
- **Trend:**
91
- ```j1ql
92
- FIND User AS u
93
- RETURN count(u) AS value
94
- ```
95
- **Non-Trend:**
96
- ```j1ql
97
- FIND User AS u
98
- RETURN count(u) AS value
99
- ```
100
-
101
- ---
102
-
103
- ## Pie Chart
104
- The pie chart displays values from one or more queries, as they relate to each other, in the form of slices of a pie. The arc length, area and central angle of a slice are all proportional to the slice's value, as it relates to the sum of all values. This type of chart is best used when you want a quick comparison of a small set of values in an aesthetically pleasing form. In the trend version of this chart you are able to track the value change of each slice value as well as the total value through a spark line to see if the data set is getting larger or smaller over time.
105
-
106
- ### Query Requirements
107
- Expects 2 or more pairs of `name` and numeric `value` properties.
108
-
109
- ### Example Queries
110
- **Trend:**
111
- ```j1ql
112
- FIND DataStore AS ds
113
- THAT RELATES TO (Account|Service) AS a
114
- RETURN
115
- a.tag.AccountName AS name,
116
- count(ds) AS value
117
- ```
118
- **Non-Trend 1:**
119
- ```j1ql
120
- FIND DataStore AS ds
121
- THAT RELATES TO (Account|Service) AS a
122
- RETURN
123
- a.tag.AccountName AS name,
124
- count(ds) AS value
125
- ```
126
- **Non-Trend 2:**
127
- ```j1ql
128
- FIND DataStore AS ds
129
- THAT RELATES TO (Account|Service) AS a
130
- RETURN
131
- count(ds) AS value
132
- ```
133
-
134
- ---
135
-
136
- ## Bar Chart
137
- The bar chart visualization allows you to view categorical data to analyze your queries with a specified x and y axis. You are able to run multiple queries and visualize the bar chart in stacked format. This chart is best suited for categorizing your results. In the trend version of the chart you are able to visualize the value change of each categorical result through a %Change indicator and a reference category bar of the result value from the previous time period selected.
138
-
139
- ### Query Requirements
140
- Expects one or more `x` and `y` values.
141
-
142
- ### Example Queries
143
- **Trend:**
144
- ```j1ql
145
- FIND Person AS p
146
- THAT IS User AS u
147
- THAT opened PR
148
- WITH state='OPEN' AS pr
149
- RETURN
150
- p.displayName AS x,
151
- count(pr) AS y
152
- ORDER BY y DESC
153
- ```
154
- **Non-Trend:**
155
- ```j1ql
156
- FIND Person AS p
157
- THAT IS User AS u
158
- THAT opened PR
159
- WITH state='OPEN' AS pr
160
- RETURN
161
- p.displayName AS x,
162
- count(pr) AS y
163
- ORDER BY y DESC
164
- LIMIT 5
165
- ```
166
-
167
- ---
168
-
169
- ## Line Chart
170
- The line chart is created by plotting a series of several points and connecting them with a straight line. This is best suited for data that has historical trend data enabled.
171
-
172
- ### Query Requirements
173
- Expects `line` and `y` values.
174
-
175
- ### Example Queries
176
- **Trend:**
177
- ```j1ql
178
- FIND Finding
179
- WITH createdOn > date.now-7day AS f
180
- RETURN
181
- count(f) AS y,
182
- f.numericSeverity AS line
183
- ```
184
- **Non-Trend:**
185
- ```j1ql
186
- FIND Finding
187
- WITH createdOn > date.now-7day AS f
188
- RETURN
189
- f.createdOn AS x,
190
- count(f) AS y,
191
- f.numericSeverity AS line
192
- ```
193
-
194
- ---
195
-
196
- ## Matrix Chart
197
- The matrix chart is used for analyzing and displaying the relationship between data sets. The matrix diagram shows the relationship between two, three, or four groups of information.
198
-
199
- ### Query Requirements
200
- Expects `x` and `y` row and column names. Optional `label` to be shown in each cell. Any additional properties returned will be shown as key: value.
201
-
202
- ### Example Queries
203
- **Firewall matrix:**
204
- ```j1ql
205
- FIND Firewall AS row
206
- THAT allows AS rel
207
- Network AS col
208
- RETURN
209
- row.displayName AS x,
210
- col.displayName AS y,
211
- rel.egress AS egress,
212
- rel.ingress AS ingress,
213
- rel.fromPort as fromPort,
214
- rel.toPort as toPort,
215
- rel.ipProtocol AS label
216
- ```
217
-
218
- ---
219
-
220
- ## Table
221
- The tables chart present data in as close to raw form as possible. Tables are meant to be read, so they are ideal when you have data that cannot easily be presented visually, or when the data requires more specific attention.
222
-
223
- ### Query Requirements
224
- Note: This chart is currently limited to displaying 250 rows, and it does not handle pagination. It is recommended to use LIMIT and ORDER BY to sort and limit the results.
225
-
226
- ### Example Queries
227
- **Most recent people:**
228
- ```j1ql
229
- FIND Person AS p
230
- RETURN
231
- p.name AS Name,
232
- p.email AS Email,
233
- p.manager AS Manager
234
- ORDER BY p._createdOn DESC
235
- LIMIT 5
236
- ```
237
-
238
- ---
239
-
240
- ## Graph Chart
241
- The graph chart displays a tree graph of query results. This chart is best used to visualize specific relationships between entities.
242
-
243
- ### Example Queries
244
- **Most recent people:**
245
- ```j1ql
246
- FIND Person RETURN TREE
247
- ```
248
-
249
- ---
250
-
251
- ## Status
252
- The status chart displays a visual summary of correlating queries. This chart is best used to show positive or negative results based on if relationships are present in query results. This chart is best suited by multiple queries.
253
-
254
- ### Example Queries
255
- **Users passing security check:**
256
- ```j1ql
257
- Find Person as p
258
- Return
259
- p.email as id,
260
- p.name as displayName,
261
- p.acceptedSecurityPolicyOn,
262
- p.backgroundCheck,
263
- p.iconWebLink as iconWebLink
264
- ```
265
- ```j1ql
266
- Find Person as p that owns Device as d
267
- Return
268
- p.email as id,
269
- d.encrypted
270
- ```
271
- ```j1ql
272
- Find Person as p that is User as u
273
- Return
274
- p.email as id,
275
- count(u)
276
- ```
277
-
278
- ---
279
-
280
- ## Area Chart
281
- The area chart is a graph that combines a line chart and a bar chart to show changes in quantities over time. This chart requires the assets in the query to have relevant dates in their properties. For the best results, these charts can be generated by J1 Questions that have trend collection enabled. (This will soon be available straight from Insights.)
282
-
283
- ### Query Requirements
284
- Expects two or more `x` and `y` values.
285
-
286
- ### Example Queries
287
- **Top 5 most open PRs by Person:**
288
- ```j1ql
289
- FIND Person AS p
290
- THAT IS User AS u
291
- THAT opened PR
292
- WITH state='OPEN' AS pr
293
- RETURN
294
- p.displayName AS x,
295
- count(pr) AS y
296
- ORDER BY y DESC
297
- LIMIT 5
298
- ```
299
-
300
- ---
301
-
302
- ## Markdown Chart
303
- The markdown chart/widget allows you to display custom Markdown content directly on your dashboard. This is useful for adding documentation, instructions, or contextual information alongside your visualizations.
304
-
305
- ### Query Requirements
306
- - No queries are required for this widget type.
307
- - The widget's settings must include a `markdown.text` property containing the Markdown content to display.
308
-
309
- ### Example Configuration
310
- **Simple Markdown widget:**
311
- ```json
312
- {
313
- "type": "markdown",
314
- "config": {
315
- "queries": [],
316
- "settings": {
317
- "markdown": {
318
- "text": "# test markdown here\nsome more content"
319
- }
320
- }
321
- }
322
- }
323
- ```
324
-
325
- ---