-
Notifications
You must be signed in to change notification settings - Fork 0
/
json.go
111 lines (96 loc) · 3.17 KB
/
json.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package main
import "time"
// AnnotationsReq encodes the information provided by Grafana in its requests.
type AnnotationsReq struct {
Range Range `json:"range"`
Annotation Annotation `json:"annotation"`
}
// Range specifies the time range the request is valid for.
type Range struct {
From time.Time `json:"from"`
To time.Time `json:"to"`
}
// RangeRaw specifies the time range the request is valid for.
type RangeRaw struct {
From string `json:"from"`
To string `json:"to"`
}
// Annotation is the object passed by Grafana when it fetches annotations.
//
// http://docs.grafana.org/plugins/developing/datasources/#annotation-query
type Annotation struct {
// Name must match in the request and response
Name string `json:"name"`
Datasource string `json:"datasource"`
IconColor string `json:"iconColor"`
Enable bool `json:"enable"`
ShowLine bool `json:"showLine"`
Query string `json:"query"`
}
// AnnotationResponse contains all the information needed to render an
// annotation event.
//
// https://github.com/grafana/simple-json-datasource#annotation-api
type AnnotationResponse struct {
// The original annotation sent from Grafana.
Annotation Annotation `json:"annotation"`
// Time since UNIX Epoch in milliseconds. (required)
Time int64 `json:"time"`
// The title for the annotation tooltip. (required)
Title string `json:"title"`
// Tags for the annotation. (optional)
Tags string `json:"tags"`
// Text for the annotation. (optional)
Text string `json:"text"`
}
// QueryTarget query targets field
type QueryTarget struct {
ReferenceID string `json:"refId"`
Target string `json:"target"`
Hide bool `json:"hide"`
Type string `json:"type"`
}
// Metric is a metric type
type Metric struct {
Text interface{} `json:"text"`
Value interface{} `json:"value"`
}
// TableColumn response table column
type TableColumn struct {
Text string `json:"text"`
Type string `json:"type"`
}
// QueryResponseTimeserie grafana timeserie query response
type QueryResponseTimeserie struct {
Target string `json:"target"`
DataPoints [][]interface{} `json:"datapoints"`
}
// QueryResponseTable grafana table query response
type QueryResponseTable struct {
Type string `json:"type"`
Columns []TableColumn `json:"columns"`
Rows [][]interface{} `json:"rows"`
Target string `json:"target"`
}
// QueryRequest grafana query request
type QueryRequest struct {
Timezone string `json:"timezone"`
PanelID int `json:"panelId"`
Range Range `json:"range"`
RangeRaw RangeRaw `json:"rangeRaw"`
Interval string `json:"interval"`
Targets []QueryTarget `json:"targets"`
Format string `json:"format"`
MaxDataPoints int64 `json:"maxDataPoints"`
IntervalMs int `json:"intervalMs"`
Type string `json:"type"`
ScopedVars map[string]Metric `json:"scopedVars"`
}
// QueryResponse grafana query response
type QueryResponse struct {
Data interface{} `json:"data"`
}
// SearchResponse grafana search response
type SearchResponse struct {
Data []string `json:"data"`
}