Skip to content

Commit

Permalink
Add support for Mirabelle
Browse files Browse the repository at this point in the history
In Mirabelle https://github.com/mcorbin/Mirabelle websocket events
have timestamp in fractional seconds.
  • Loading branch information
faxm0dem committed May 5, 2021
1 parent c84ed0b commit 38430fd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2021-04-30 Release v0.1.5

* Add support for events with numeric time (in seconds)
This makes this plugin also compatible with Mirabelle
https://github.com/mcorbin/mirabelle

## 2021-01-28 Release v0.1.4

* Fix time scrolling in Grafana 7.4.x
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ccin2p3-riemann-datasource",
"version": "0.1.4",
"version": "0.1.5",
"description": "Subscribe to riemann.io websocket streams!",
"scripts": {
"build": "grafana-toolkit plugin:build",
Expand Down
12 changes: 11 additions & 1 deletion src/DataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,17 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
return new Observable<DataQueryResponse>(subscriber => {
ws.onmessage = function(event) {
var parsedEvent = JSON.parse(event.data);
parsedEvent['time'] = new Date(parsedEvent['time']).getTime();
var typeOfTime = typeof parsedEvent['time'];
if (typeOfTime === 'number') {
// Mirabelle sends time as (fractional) seconds
parsedEvent['time'] *= 1000;
// Riemann sends time as Isodate string
} else if (typeOfTime === 'string') {
parsedEvent['time'] = new Date(parsedEvent['time']).getTime();
// In any other case, use current time
} else {
parsedEvent['time'] = new Date().getTime();
}
const seriesId = getSeriesId(event, ...query.groupBy);
let frame: CircularDataFrame;
if (seriesId in seriesList) {
Expand Down

0 comments on commit 38430fd

Please sign in to comment.