Skip to content

Commit 68b2d75

Browse files
authored
Fix type guess (#23)
1 parent 5dbcd25 commit 68b2d75

File tree

9 files changed

+49
-17
lines changed

9 files changed

+49
-17
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ This dashboard is aimed at visualizing the logs stored in the Parseable demo ser
3333
![query editor](https://github.com/parseablehq/parseable-datasource/blob/main/src/img/query-editor.png?raw=true)
3434
![log dashboard](https://github.com/parseablehq/parseable-datasource/blob/main/src/img/log-visualisation.png?raw=true)
3535
![log text view](https://github.com/parseablehq/parseable-datasource/blob/main/src/img/log-view-text.png?raw=true)
36+
37+
## Credits
38+
39+
This plugin is developed in collaboration with our friends at [Technocube](https://www.technocube.co/). Thanks to them for their support and contribution.

dist/MANIFEST.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ Hash: SHA512
99
"signedByOrgName": "parseable",
1010
"plugin": "parseable-parseable-datasource",
1111
"version": "1.0.2",
12-
"time": 1678091287733,
12+
"time": 1678116427014,
1313
"keyId": "7e4d0c6a708866e7",
1414
"files": {
1515
"LICENSE": "20b067f86de375aae6db0f283ab2e65de24d537733b89bd58432c101259d84cf",
1616
"CHANGELOG.md": "ba613d6f914b27dce9ace4d8c0cb074273c9eb6c536d8e7ac24c5ce6ae941fd0",
17-
"module.js.map": "98ca780abf736bc47e7fbf2e5b3e534fca3acb7899bd6769f99fdff694477dc1",
17+
"module.js.map": "7189edd1ce6145446698271b0a58dfc3f14444d1e3ffe3ea885e07ca1620af8a",
1818
"plugin.json": "9aeb4b12dc39425b139e9818c0b9f4c30314de6387bf5c8802deb7e36eed6a57",
1919
"README.md": "030a05e0d49d3746ef272d53c99936e3b98e3219a1cac96ca1df48ddee475934",
2020
"img/configuration.png": "c545a51bcc88809b2b4f87aac517a7d27ad61281344b0485c9826370b915b4d8",
@@ -30,18 +30,18 @@ Hash: SHA512
3030
"stories/assets/code-brackets.svg": "9ef6443ebd43351be1a6edbab492003b84f2e30c8f80207ec8c4138fa440f7f4",
3131
"stories/assets/flow.svg": "275142c67bb630246cbdfb0fc3493f17dd695544777ec8da852dbbe94976d323",
3232
"stories/assets/repo.svg": "fb4ece472009833a03b9f1fbc775f13a010d9432cae3844e8b05710ba028100d",
33-
"module.js": "7fc14ff69e541ecc8b27ed7c6e118839c109639672dde85effbcac87372e5de7",
34-
"dashboards/log-view.json": "7e6003d2b0b2f0913576908a3c76306b21bb8b53b4343eb379d986ee9e7cce34"
33+
"module.js": "08c7db3293d45747bf8aa5c99a3b6bb9e6a12d48f358b4e034c60ec3f2381f7f",
34+
"dashboards/log-view.json": "224d921c8a5a4c3ed426de83f8f70ddb6406690687423b15e6e5822190bcb64c"
3535
}
3636
}
3737
-----BEGIN PGP SIGNATURE-----
3838
Version: OpenPGP.js v4.10.10
3939
Comment: https://openpgpjs.org
4040

41-
wrkEARMKAAYFAmQFpBcAIQkQfk0ManCIZucWIQTzOyW2kQdOhGNlcPN+TQxq
42-
cIhm501IAgkB1WA0MsZjjYjtnXs7zy1JWvJ4jz79wCupBo3Q4bW6oJu50ArI
43-
uxDUCnCN8KxlGHFNiKSQeFlPdsgm9GNjKhgbf6MCCQFf7Cz902ksGnQSHlnA
44-
KmXHsXRNJYsI165Y9pJA5jQUQfDf71br0nPoggUtHU2cKpJvUrE9amF2zoHn
45-
hcEDcrB/Gw==
46-
=JuLg
41+
wrcEARMKAAYFAmQGBksAIQkQfk0ManCIZucWIQTzOyW2kQdOhGNlcPN+TQxq
42+
cIhm5xzGAgY8M1HwqILkK/r9A/kbQdqZUMnRwWoqmk/rF0Iy/QZBJwtOxfx/
43+
1as1g5GpBzNshpJttopD0cQuyjcu89ZFYRWIwAIFFfp1noxjDozs/Dex0yKV
44+
wiwDqSjus2rxBNm3Yw7YSqXNgLymJRC/BnG+3g0MYeK1iKccy9tWqG9iBpuw
45+
Cdjl1Uk=
46+
=aVxm
4747
-----END PGP SIGNATURE-----

dist/dashboards/log-view.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"label": "Parseable",
66
"description": "",
77
"type": "datasource",
8-
"pluginId": "parseable-datasource",
8+
"pluginId": "parseable-parseable-datasource",
99
"pluginName": "Parseable"
1010
}
1111
],

dist/module.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/module.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
662 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c79c4576d9db03184ff77ca9f0b67795ed1d9cd4
1+
514ca07b4f149d8579525ee4d91aa90f261e6d12

src/dashboards/log-view.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"label": "Parseable",
66
"description": "",
77
"type": "datasource",
8-
"pluginId": "parseable-datasource",
8+
"pluginId": "parseable-parseable-datasource",
99
"pluginName": "Parseable"
1010
}
1111
],

src/datasource.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import {
44
DataQueryResponse,
55
DataSourceApi,
66
DataSourceInstanceSettings,
7-
toDataFrame,
7+
MutableDataFrame,
8+
DataFrame,
9+
FieldType,
10+
guessFieldTypeFromValue,
811
} from '@grafana/data';
912
import { lastValueFrom, of } from 'rxjs';
1013
import { catchError, map } from 'rxjs/operators';
@@ -68,7 +71,7 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
6871
method: 'POST',
6972
}).pipe(
7073
map((response) => {
71-
return toDataFrame(response.data);
74+
return this.arrayToDataFrame(response.data);
7275
}),
7376
catchError((err) => {
7477
return of({ data: [] });
@@ -83,6 +86,31 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
8386
};
8487
}
8588

89+
arrayToDataFrame(array: any[]): DataFrame {
90+
let dataFrame: MutableDataFrame = new MutableDataFrame();
91+
92+
if (array.length > 0) {
93+
const fields = Object.keys(array[0]).map(field => {
94+
return { name: field, type: guessFieldTypeFromValue(array[0][field]) };
95+
});
96+
for (const field of fields) {
97+
// p_timestamp is always a time field present in the log
98+
// stream as server adds it to the log
99+
if (field.name.toLowerCase() === 'p_timestamp') {
100+
field.type = FieldType.time;
101+
break;
102+
}
103+
}
104+
dataFrame = new MutableDataFrame({ fields });
105+
}
106+
107+
array.forEach((row) => {
108+
dataFrame.appendRow(Object.values(row));
109+
});
110+
111+
return dataFrame;
112+
}
113+
86114
doFetch<T>(options: BackendSrvRequest) {
87115
options.withCredentials = this.withCredentials;
88116
options.headers = this.headers;

0 commit comments

Comments
 (0)