Skip to content

Commit 31a4431

Browse files
committed
Use 'pipe' variable format instead of default
Previously, when user selected multiple variables, this query ``` service ~= "$service" ``` was expanded into ``` service ~= "{svc1, svc2}" ``` After the change, it will be turned correctly into ``` service ~= "svc1|svc2" ``` We use `pipe` instead of `regex` because there seems to be a bug in riemann that will make the following fail ``` host ~= "host1\.example\.com|host2\.example\.com" ``` pipe doesn't backslash the dot but this is a workaround i
1 parent 38430fd commit 31a4431

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2022-09-21 Release v0.1.6
4+
5+
* Improve variable handling by interpolating multiple selections as "regex"
6+
37
## 2021-04-30 Release v0.1.5
48

59
* Add support for events with numeric time (in seconds)

Changes.md

-5
This file was deleted.

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ This is the query text that will define the websocket subscription.
126126
The riemann query language doesn't have proper documentation yet, but there are lots of examples on its [website](https://riemann.io)
127127
and on the [test suite](https://github.com/riemann/riemann/blob/master/test/riemann/query_test.clj).
128128

129+
If you use variable interpolation and use multiple selections, make sure to use the regexp match.
130+
129131
#### Examples
130132

131133
```
@@ -135,6 +137,12 @@ metric and state = "ok"
135137
metric = 42
136138
```
137139

140+
```
141+
service ~= "$service"
142+
# When multiple services are selected, this will expand to
143+
# service ~= "service1|service2|service3"
144+
```
145+
138146
### GroupBy
139147

140148
Riemann will potentially send you a truckload of unrelated events, unless your query is specific enough.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ccin2p3-riemann-datasource",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "Subscribe to riemann.io websocket streams!",
55
"scripts": {
66
"build": "grafana-toolkit plugin:build",

src/DataSource.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class DataSource extends DataSourceApi<MyQuery, MyDataSourceOptions> {
4242
query(options: DataQueryRequest<MyQuery>): Observable<DataQueryResponse> {
4343
const streams = options.targets.map(target => {
4444
const query = defaults(target, defaultQuery);
45-
const queryText = getTemplateSrv().replace(query.queryText, options.scopedVars);
45+
const queryText = getTemplateSrv().replace(query.queryText, options.scopedVars, 'pipe');
4646
let ws: WebSocket;
4747
if (queryText in this.wsList) {
4848
cons.trace('Using existing ws for query', queryText);

0 commit comments

Comments
 (0)