Skip to content

Commit 2cd056a

Browse files
author
Stan van Rooy
authored
feat: add backend plugin to make alerting possible (#37)
This PR implements the backend part of the plugin. This makes it possible to, for example, create alerts in Grafana, based on data retrieved from Parseable. Example of creating an alert: https://github.com/parseablehq/parseable-datasource/assets/49564025/41cd6e5a-5131-48a4-8d6f-69513b05c7aa
1 parent 58ad7c6 commit 2cd056a

File tree

8 files changed

+792
-2
lines changed

8 files changed

+792
-2
lines changed

.github/workflows/ci.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
if: steps.check-for-backend.outputs.has-backend == 'true'
6060
uses: actions/setup-go@v2
6161
with:
62-
go-version: "1.15"
62+
go-version: "1.21"
6363

6464
- name: Test backend
6565
if: steps.check-for-backend.outputs.has-backend == 'true'
@@ -73,4 +73,4 @@ jobs:
7373
uses: magefile/mage-action@v1
7474
with:
7575
version: latest
76-
args: buildAll
76+
args: buildAll

Magefile.go

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//go:build mage
2+
// +build mage
3+
package main
4+
5+
import (
6+
"github.com/magefile/mage/mg"
7+
8+
// mage:import
9+
build "github.com/grafana/grafana-plugin-sdk-go/build"
10+
"github.com/magefile/mage/sh"
11+
"os"
12+
"path"
13+
)
14+
15+
// Default configures the default target.
16+
var Default = build.BuildAll
17+
18+
// Server builds the example server inside cmd/server
19+
func Server() error {
20+
os.Chdir(path.Join("cmd", "server"))
21+
defer os.Chdir(path.Join("..", ".."))
22+
if err := sh.Run("go", "build", "-v"); err != nil {
23+
return err
24+
}
25+
return nil
26+
}
27+
28+
// CleanAll runs the 'clean' target and also removes the example server binary in cmd/server
29+
func CleanAll() error {
30+
mg.Deps(build.Clean)
31+
return os.Remove(path.Join("cmd", "server", "server"))
32+
}
33+
34+
// TestAll runs all test for the backend (go test ./...), it's different than 'test', which runs tests only
35+
// in the pkg package.
36+
func TestAll() error {
37+
return sh.RunV("go", "test", "./...")
38+
}

go.mod

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
module github.com/parseablehq/parseable-datasource
2+
3+
go 1.20
4+
5+
require (
6+
github.com/grafana/grafana-plugin-sdk-go v0.187.0
7+
github.com/magefile/mage v1.15.0
8+
github.com/stretchr/testify v1.8.4
9+
go.opentelemetry.io/otel v1.19.0
10+
go.opentelemetry.io/otel/trace v1.19.0
11+
)
12+
13+
require (
14+
cloud.google.com/go/compute/metadata v0.2.3 // indirect
15+
github.com/BurntSushi/toml v1.3.2 // indirect
16+
github.com/apache/arrow/go/v13 v13.0.0 // indirect
17+
github.com/beorn7/perks v1.0.1 // indirect
18+
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
19+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
20+
github.com/cheekybits/genny v1.0.0 // indirect
21+
github.com/chromedp/cdproto v0.0.0-20220208224320-6efb837e6bc2 // indirect
22+
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
23+
github.com/davecgh/go-spew v1.1.1 // indirect
24+
github.com/elazarl/goproxy v0.0.0-20230731152917-f99041a5c027 // indirect
25+
github.com/fatih/color v1.15.0 // indirect
26+
github.com/getkin/kin-openapi v0.120.0 // indirect
27+
github.com/go-logr/logr v1.2.4 // indirect
28+
github.com/go-logr/stdr v1.2.2 // indirect
29+
github.com/go-openapi/jsonpointer v0.19.6 // indirect
30+
github.com/go-openapi/swag v0.22.4 // indirect
31+
github.com/goccy/go-json v0.10.0 // indirect
32+
github.com/golang/protobuf v1.5.3 // indirect
33+
github.com/google/flatbuffers v23.1.21+incompatible // indirect
34+
github.com/google/go-cmp v0.5.9 // indirect
35+
github.com/google/uuid v1.3.0 // indirect
36+
github.com/gorilla/mux v1.8.0 // indirect
37+
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
38+
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
39+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2 // indirect
40+
github.com/hashicorp/go-hclog v1.5.0 // indirect
41+
github.com/hashicorp/go-plugin v1.4.9 // indirect
42+
github.com/hashicorp/yamux v0.1.1 // indirect
43+
github.com/invopop/yaml v0.2.0 // indirect
44+
github.com/josharian/intern v1.0.0 // indirect
45+
github.com/json-iterator/go v1.1.12 // indirect
46+
github.com/klauspost/compress v1.15.15 // indirect
47+
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
48+
github.com/mailru/easyjson v0.7.7 // indirect
49+
github.com/mattetti/filebuffer v1.0.1 // indirect
50+
github.com/mattn/go-colorable v0.1.13 // indirect
51+
github.com/mattn/go-isatty v0.0.18 // indirect
52+
github.com/mattn/go-runewidth v0.0.9 // indirect
53+
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
54+
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
55+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
56+
github.com/modern-go/reflect2 v1.0.2 // indirect
57+
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
58+
github.com/oklog/run v1.1.0 // indirect
59+
github.com/olekukonko/tablewriter v0.0.5 // indirect
60+
github.com/perimeterx/marshmallow v1.1.5 // indirect
61+
github.com/pierrec/lz4/v4 v4.1.17 // indirect
62+
github.com/pmezard/go-difflib v1.0.0 // indirect
63+
github.com/prometheus/client_golang v1.14.0 // indirect
64+
github.com/prometheus/client_model v0.3.0 // indirect
65+
github.com/prometheus/common v0.42.0 // indirect
66+
github.com/prometheus/procfs v0.8.0 // indirect
67+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
68+
github.com/unknwon/bra v0.0.0-20200517080246-1e3013ecaff8 // indirect
69+
github.com/unknwon/com v1.0.1 // indirect
70+
github.com/unknwon/log v0.0.0-20150304194804-e617c87089d3 // indirect
71+
github.com/urfave/cli v1.22.14 // indirect
72+
github.com/zeebo/xxh3 v1.0.2 // indirect
73+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.45.0 // indirect
74+
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.45.0 // indirect
75+
go.opentelemetry.io/contrib/propagators/jaeger v1.20.0 // indirect
76+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect
77+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect
78+
go.opentelemetry.io/otel/metric v1.19.0 // indirect
79+
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
80+
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
81+
golang.org/x/mod v0.9.0 // indirect
82+
golang.org/x/net v0.17.0 // indirect
83+
golang.org/x/sys v0.13.0 // indirect
84+
golang.org/x/text v0.13.0 // indirect
85+
golang.org/x/tools v0.6.0 // indirect
86+
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
87+
google.golang.org/genproto/googleapis/api v0.0.0-20230731193218-e0aa005b6bdf // indirect
88+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230731193218-e0aa005b6bdf // indirect
89+
google.golang.org/grpc v1.58.2 // indirect
90+
google.golang.org/protobuf v1.31.0 // indirect
91+
gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect
92+
gopkg.in/yaml.v3 v3.0.1 // indirect
93+
)

0 commit comments

Comments
 (0)