Update layout ylabel and yrange to be properties of the query.

pull/632/head
Chris Goller 2016-11-29 15:04:54 -06:00 committed by Will Piers
parent 33ea32c8b2
commit 66ac6af136
7 changed files with 428 additions and 266 deletions

View File

@ -107,12 +107,18 @@ func MarshalLayout(l chronograf.Layout) ([]byte, error) {
for i, c := range l.Cells {
queries := make([]*Query, len(c.Queries))
for j, q := range c.Queries {
r := new(Range)
if q.Range != nil {
r.Upper, r.Lower = q.Range.Upper, q.Range.Lower
}
queries[j] = &Query{
Command: q.Command,
DB: q.DB,
RP: q.RP,
GroupBys: q.GroupBys,
Wheres: q.Wheres,
Label: q.Label,
Range: r,
}
}
@ -122,8 +128,6 @@ func MarshalLayout(l chronograf.Layout) ([]byte, error) {
W: c.W,
H: c.H,
I: c.I,
Yranges: c.YRanges,
Ylabels: c.YLabels,
Name: c.Name,
Queries: queries,
}
@ -158,6 +162,13 @@ func UnmarshalLayout(data []byte, l *chronograf.Layout) error {
RP: q.RP,
GroupBys: q.GroupBys,
Wheres: q.Wheres,
Label: q.Label,
}
if q.Range.Upper != q.Range.Lower {
queries[j].Range = &chronograf.Range{
Upper: q.Range.Upper,
Lower: q.Range.Lower,
}
}
}
@ -167,8 +178,6 @@ func UnmarshalLayout(data []byte, l *chronograf.Layout) error {
W: c.W,
H: c.H,
I: c.I,
YRanges: c.Yranges,
YLabels: c.Ylabels,
Name: c.Name,
Queries: queries,
}

View File

@ -15,6 +15,7 @@ It has these top-level messages:
Layout
Cell
Query
Range
AlertRule
User
*/
@ -130,6 +131,8 @@ type Query struct {
RP string `protobuf:"bytes,3,opt,name=RP,proto3" json:"RP,omitempty"`
GroupBys []string `protobuf:"bytes,4,rep,name=GroupBys" json:"GroupBys,omitempty"`
Wheres []string `protobuf:"bytes,5,rep,name=Wheres" json:"Wheres,omitempty"`
Label string `protobuf:"bytes,6,opt,name=Label,proto3" json:"Label,omitempty"`
Range *Range `protobuf:"bytes,7,opt,name=Range" json:"Range,omitempty"`
}
func (m *Query) Reset() { *m = Query{} }
@ -137,6 +140,23 @@ func (m *Query) String() string { return proto.CompactTextString(m) }
func (*Query) ProtoMessage() {}
func (*Query) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{5} }
func (m *Query) GetRange() *Range {
if m != nil {
return m.Range
}
return nil
}
type Range struct {
Upper int64 `protobuf:"varint,1,opt,name=Upper,proto3" json:"Upper,omitempty"`
Lower int64 `protobuf:"varint,2,opt,name=Lower,proto3" json:"Lower,omitempty"`
}
func (m *Range) Reset() { *m = Range{} }
func (m *Range) String() string { return proto.CompactTextString(m) }
func (*Range) ProtoMessage() {}
func (*Range) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{6} }
type AlertRule struct {
ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"`
JSON string `protobuf:"bytes,2,opt,name=JSON,proto3" json:"JSON,omitempty"`
@ -147,7 +167,7 @@ type AlertRule struct {
func (m *AlertRule) Reset() { *m = AlertRule{} }
func (m *AlertRule) String() string { return proto.CompactTextString(m) }
func (*AlertRule) ProtoMessage() {}
func (*AlertRule) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{6} }
func (*AlertRule) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{7} }
type User struct {
ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
@ -157,7 +177,7 @@ type User struct {
func (m *User) Reset() { *m = User{} }
func (m *User) String() string { return proto.CompactTextString(m) }
func (*User) ProtoMessage() {}
func (*User) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{7} }
func (*User) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{8} }
func init() {
proto.RegisterType((*Exploration)(nil), "internal.Exploration")
@ -166,6 +186,7 @@ func init() {
proto.RegisterType((*Layout)(nil), "internal.Layout")
proto.RegisterType((*Cell)(nil), "internal.Cell")
proto.RegisterType((*Query)(nil), "internal.Query")
proto.RegisterType((*Range)(nil), "internal.Range")
proto.RegisterType((*AlertRule)(nil), "internal.AlertRule")
proto.RegisterType((*User)(nil), "internal.User")
}
@ -173,42 +194,45 @@ func init() {
func init() { proto.RegisterFile("internal.proto", fileDescriptorInternal) }
var fileDescriptorInternal = []byte{
// 583 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x94, 0x5f, 0x6e, 0xd3, 0x4e,
0x10, 0xc7, 0xb5, 0xb1, 0x9d, 0xc4, 0xd3, 0x9f, 0xfa, 0x43, 0xab, 0x0a, 0xad, 0x10, 0x0f, 0x96,
0xc5, 0x83, 0x91, 0x50, 0x1f, 0xe0, 0x04, 0x69, 0x5d, 0xa1, 0x40, 0x29, 0x65, 0xdb, 0x8a, 0x27,
0x1e, 0xb6, 0xcd, 0xb4, 0xb5, 0xb4, 0xb1, 0xcd, 0xda, 0x26, 0xf1, 0x1d, 0x38, 0x03, 0x97, 0xe0,
0x00, 0x70, 0x34, 0x34, 0xeb, 0xb5, 0x63, 0x89, 0x3f, 0xea, 0xdb, 0x7c, 0x67, 0x26, 0xb3, 0x9f,
0xfd, 0xee, 0xc4, 0xb0, 0x9f, 0xe5, 0x35, 0x9a, 0x5c, 0xe9, 0xc3, 0xd2, 0x14, 0x75, 0xc1, 0xe7,
0xbd, 0x8e, 0xbf, 0x33, 0xd8, 0x3b, 0xd9, 0x96, 0xba, 0x30, 0xaa, 0xce, 0x8a, 0x9c, 0xef, 0xc3,
0x64, 0x99, 0x0a, 0x16, 0xb1, 0xc4, 0x93, 0x93, 0x65, 0xca, 0x39, 0xf8, 0x67, 0x6a, 0x8d, 0x62,
0x12, 0xb1, 0x24, 0x94, 0x36, 0xe6, 0x8f, 0x61, 0x7a, 0x55, 0xa1, 0x59, 0xa6, 0xc2, 0xb3, 0x7d,
0x4e, 0x51, 0x6f, 0xaa, 0x6a, 0x25, 0xfc, 0xae, 0x97, 0x62, 0xfe, 0x14, 0xc2, 0x63, 0x83, 0xaa,
0xc6, 0xd5, 0x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b, 0xe2, 0x8d, 0x16, 0x84, 0xc6, 0xbf, 0x55, 0xa5, 0x5a, 0xa6, 0xd6, 0x51, 0x4f, 0x3a,
0x15, 0xbf, 0x00, 0x9f, 0x16, 0x71, 0x34, 0xd9, 0xb7, 0x93, 0x0f, 0x20, 0x38, 0x59, 0xab, 0x4c,
0xbb, 0xd1, 0x9d, 0xb8, 0x9e, 0xda, 0xef, 0xcf, 0xab, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x47,
0x4e, 0x32, 0xc9, 0x91, 0x04, 0x00, 0x00,
// 626 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x94, 0x5f, 0x6e, 0xd3, 0x4c,
0x10, 0xc0, 0xb5, 0xb1, 0x9d, 0xc4, 0xdb, 0x4f, 0xfd, 0xd0, 0xaa, 0x42, 0x2b, 0xc4, 0x83, 0x65,
0x81, 0x14, 0x24, 0xd4, 0x07, 0x7a, 0x82, 0xb4, 0xae, 0x50, 0xa0, 0x94, 0xb2, 0x6d, 0xc4, 0x13,
0x0f, 0xdb, 0x66, 0xda, 0x5a, 0xda, 0xd8, 0x66, 0x6d, 0x93, 0xfa, 0x0e, 0x9c, 0x81, 0x43, 0xc0,
0x01, 0xe0, 0x68, 0x68, 0x66, 0xd7, 0x49, 0x10, 0x7f, 0xd4, 0xb7, 0xfd, 0xed, 0x4c, 0xc7, 0xbf,
0x99, 0x9d, 0x86, 0xef, 0xe6, 0x45, 0x03, 0xb6, 0xd0, 0x66, 0xbf, 0xb2, 0x65, 0x53, 0x8a, 0x71,
0xcf, 0xe9, 0x37, 0xc6, 0x77, 0x8e, 0xef, 0x2a, 0x53, 0x5a, 0xdd, 0xe4, 0x65, 0x21, 0x76, 0xf9,
0x60, 0x96, 0x49, 0x96, 0xb0, 0x49, 0xa0, 0x06, 0xb3, 0x4c, 0x08, 0x1e, 0x9e, 0xea, 0x25, 0xc8,
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58, 0xad, 0x19, 0xff, 0x2d, 0xdf, 0xdf, 0x82, 0xf5, 0xfd, 0xc5, 0xca, 0x13, 0x3e, 0xf8, 0x09,
0x1a, 0xf8, 0x8e, 0x1c, 0x88, 0xa7, 0x3c, 0x52, 0x68, 0x4c, 0x6d, 0xfd, 0x32, 0x0c, 0xba, 0x56,
0x2e, 0x9a, 0x1e, 0xf8, 0x34, 0xac, 0x32, 0xaf, 0x2a, 0xb0, 0x7e, 0x4f, 0x1d, 0x50, 0xed, 0x72,
0x05, 0x96, 0x94, 0x03, 0xe5, 0x20, 0xfd, 0xc0, 0xe3, 0xa9, 0x01, 0xdb, 0xa8, 0xd6, 0xc0, 0x6f,
0xeb, 0x24, 0x78, 0xf8, 0xea, 0xfc, 0xed, 0x69, 0xbf, 0xdd, 0x78, 0xde, 0xec, 0x64, 0xb0, 0xb5,
0x93, 0xd8, 0xd0, 0x6b, 0x5d, 0xe9, 0x59, 0x46, 0x8f, 0x18, 0x28, 0x4f, 0xe9, 0x73, 0x1e, 0xe2,
0xee, 0x6f, 0x55, 0x0e, 0xa9, 0xf2, 0x1e, 0x8f, 0x8e, 0x97, 0x3a, 0x37, 0xbe, 0xb4, 0x83, 0xcb,
0x21, 0xfd, 0xe4, 0x1d, 0xfc, 0x0c, 0x00, 0x00, 0xff, 0xff, 0x4e, 0xdb, 0x24, 0x8b, 0x04, 0x05,
0x00, 0x00,
}

View File

@ -57,6 +57,13 @@ message Query {
string RP = 3; // RP is a retention policy and optional;
repeated string GroupBys= 4; // GroupBys define the groups to combine in the query
repeated string Wheres = 5; // Wheres define the restrictions on the query
string Label = 6; // Label is the name of the Y-Axis
Range Range = 7; // Range is the upper and lower bound of the Y-Axis
}
message Range {
int64 Upper = 1; // Upper is the upper-bound of the range
int64 Lower = 2; // Lower is the lower-bound of the range
}
message AlertRule {

View File

@ -79,16 +79,19 @@ func TestMarshalLayout(t *testing.T) {
Application: "app",
Cells: []chronograf.Cell{
{
X: 1,
Y: 1,
W: 4,
H: 4,
I: "anotherid",
YRanges: []int64{1, 2},
YLabels: []string{"y1", "y2"},
Name: "cell1",
X: 1,
Y: 1,
W: 4,
H: 4,
I: "anotherid",
Name: "cell1",
Queries: []chronograf.Query{
{
Range: &chronograf.Range{
Lower: 1,
Upper: 2,
},
Label: "y1",
Command: "select mean(usage_user) as usage_user from cpu",
Wheres: []string{
`"host"="myhost"`,

View File

@ -53,13 +53,21 @@ type TimeSeries interface {
Connect(context.Context, *Source) error
}
// Range represents an upper and lower bound for data
type Range struct {
Upper int64 `json:"upper,omitempty"` // Upper is the upper bound
Lower int64 `json:"lower,omitempty"` // Lower is the lower bound
}
// Query retrieves a Response from a TimeSeries.
type Query struct {
Command string `json:"query"` // Command is the query itself
DB string `json:"db,omitempty"` // DB is optional and if empty will not be used.
RP string `json:"rp,omitempty"` // RP is a retention policy and optional; if empty will not be used.
Wheres []string `json:"wheres"` // Wheres restricts the query to certain attributes
GroupBys []string `json:"groupbys"` // GroupBys collate the query by these tags
Command string `json:"query"` // Command is the query itself
DB string `json:"db,omitempty"` // DB is optional and if empty will not be used.
RP string `json:"rp,omitempty"` // RP is a retention policy and optional; if empty will not be used.
Wheres []string `json:"wheres,omitempty"` // Wheres restricts the query to certain attributes
GroupBys []string `json:"groupbys,omitempty"` // GroupBys collate the query by these tags
Label string `json:"label,omitempty"` // Label is the Y-Axis label for the data
Range *Range `json:"range,omitempty"` // Range is the default Y-Axis range for the data
}
// Response is the result of a query against a TimeSeries
@ -245,15 +253,13 @@ type ExplorationStore interface {
// Cell is a rectangle and multiple time series queries to visualize.
type Cell struct {
X int32 `json:"x"`
Y int32 `json:"y"`
W int32 `json:"w"`
H int32 `json:"h"`
I string `json:"i"`
YRanges []int64 `json:"yranges"` // YRanges are the initial limits of the y-axes
YLabels []string `json:"ylabels"` // YLabels are the labels of the y-axes (possible to have more than one)
Name string `json:"name"`
Queries []Query `json:"queries"`
X int32 `json:"x"`
Y int32 `json:"y"`
W int32 `json:"w"`
H int32 `json:"h"`
I string `json:"i"`
Name string `json:"name"`
Queries []Query `json:"queries"`
}
// Layout is a collection of Cells for visualization

View File

@ -18,14 +18,6 @@ func newLayoutResponse(layout chronograf.Layout) layoutResponse {
httpAPILayouts := "/chronograf/v1/layouts"
href := fmt.Sprintf("%s/%s", httpAPILayouts, layout.ID)
rel := "self"
for i, c := range layout.Cells {
if c.YLabels == nil {
layout.Cells[i].YLabels = make([]string, 0)
}
if c.YRanges == nil {
layout.Cells[i].YRanges = make([]int64, 0)
}
}
return layoutResponse{
Layout: layout,
Link: link{
@ -179,10 +171,6 @@ func ValidLayoutRequest(l chronograf.Layout) error {
if c.W == 0 || c.H == 0 {
return fmt.Errorf("w, and h required")
}
// Y-Range must come in pairs (I'm leaving the option open for multiple y-axes)
if len(c.YRanges)%2 != 0 {
return fmt.Errorf("Incorrect length of yrange: %d", len(c.YRanges))
}
for _, q := range c.Queries {
if q.Command == "" {
return fmt.Errorf("query required")

View File

@ -18,7 +18,9 @@
"paths": {
"/": {
"get": {
"tags": ["routes"],
"tags": [
"routes"
],
"summary": "Lists all the endpoints",
"description": "List of the endpoints.",
"responses": {
@ -39,7 +41,9 @@
},
"/sources": {
"get": {
"tags": ["sources"],
"tags": [
"sources"
],
"summary": "Configured data sources",
"description": "These data sources store time series data.",
"responses": {
@ -58,7 +62,9 @@
}
},
"post": {
"tags": ["sources"],
"tags": [
"sources"
],
"summary": "Create new data source",
"parameters": [
{
@ -95,7 +101,9 @@
},
"/sources/{id}": {
"get": {
"tags": ["sources"],
"tags": [
"sources"
],
"parameters": [
{
"name": "id",
@ -129,7 +137,9 @@
}
},
"patch": {
"tags": ["sources"],
"tags": [
"sources"
],
"summary": "Update data source configuration",
"parameters": [
{
@ -171,7 +181,9 @@
}
},
"delete": {
"tags": ["sources"],
"tags": [
"sources"
],
"parameters": [
{
"name": "id",
@ -203,7 +215,10 @@
},
"/sources/{id}/proxy": {
"post": {
"tags": ["sources", "proxy"],
"tags": [
"sources",
"proxy"
],
"description": "Query the backend time series data source and return the response according to `format`",
"parameters": [
{
@ -259,7 +274,9 @@
},
"/users": {
"get": {
"tags": ["users"],
"tags": [
"users"
],
"summary": "List of all users on this data source",
"responses": {
"200": {
@ -277,7 +294,9 @@
}
},
"post": {
"tags": ["users"],
"tags": [
"users"
],
"summary": "Create new user for this data source",
"parameters": [
{
@ -314,7 +333,9 @@
},
"/users/{user_id}": {
"get": {
"tags": ["users"],
"tags": [
"users"
],
"parameters": [
{
"name": "user_id",
@ -348,7 +369,9 @@
}
},
"patch": {
"tags": ["users"],
"tags": [
"users"
],
"summary": "Update user configuration",
"parameters": [
{
@ -390,7 +413,9 @@
}
},
"delete": {
"tags": ["users"],
"tags": [
"users"
],
"parameters": [
{
"name": "user_id",
@ -422,8 +447,11 @@
},
"/users/{user_id}/explorations": {
"get": {
"tags": ["users", "explorations"],
"summary": "Returns all explorations for specified user",
"tags": [
"users",
"explorations"
],
"summary": "Returns all explorations for specified user",
"parameters": [
{
"name": "user_id",
@ -455,7 +483,10 @@
}
},
"post": {
"tags": ["users", "explorations"],
"tags": [
"users",
"explorations"
],
"summary": "Create new named exploration for this user",
"parameters": [
{
@ -505,7 +536,10 @@
},
"/users/{user_id}/explorations/{exploration_id}": {
"get": {
"tags": ["users", "explorations"],
"tags": [
"users",
"explorations"
],
"parameters": [
{
"name": "user_id",
@ -546,7 +580,10 @@
}
},
"patch": {
"tags": ["users", "explorations"],
"tags": [
"users",
"explorations"
],
"summary": "Update exploration configuration",
"parameters": [
{
@ -595,7 +632,10 @@
}
},
"delete": {
"tags": ["users", "explorations"],
"tags": [
"users",
"explorations"
],
"parameters": [
{
"name": "user_id",
@ -634,7 +674,10 @@
},
"/sources/{id}/kapacitors": {
"get": {
"tags": ["sources", "kapacitors"],
"tags": [
"sources",
"kapacitors"
],
"parameters": [
{
"name": "id",
@ -661,7 +704,10 @@
}
},
"post": {
"tags": ["sources", "kapacitors"],
"tags": [
"sources",
"kapacitors"
],
"summary": "Create new kapacitor backend",
"parameters": [
{
@ -705,7 +751,10 @@
},
"/sources/{id}/kapacitors/{kapa_id}": {
"get": {
"tags": ["sources", "kapacitors"],
"tags": [
"sources",
"kapacitors"
],
"parameters": [
{
"name": "id",
@ -746,7 +795,10 @@
}
},
"patch": {
"tags": ["sources", "kapacitors"],
"tags": [
"sources",
"kapacitors"
],
"summary": "Update kapacitor configuration",
"parameters": [
{
@ -795,7 +847,10 @@
}
},
"delete": {
"tags": ["sources", "kapacitors"],
"tags": [
"sources",
"kapacitors"
],
"parameters": [
{
"name": "id",
@ -834,21 +889,28 @@
},
"/sources/{id}/kapacitors/{kapa_id}/rules": {
"get": {
"tags": ["sources", "kapacitors", "rules"],
"tags": [
"sources",
"kapacitors",
"rules"
],
"description": "Get all defined alert rules.",
"parameters": [{
"name": "id",
"in": "path",
"type": "string",
"description": "ID of the source",
"required": true
}, {
"name": "kapa_id",
"in": "path",
"type": "string",
"description": "ID of the kapacitor backend.",
"required": true
}],
"parameters": [
{
"name": "id",
"in": "path",
"type": "string",
"description": "ID of the source",
"required": true
},
{
"name": "kapa_id",
"in": "path",
"type": "string",
"description": "ID of the kapacitor backend.",
"required": true
}
],
"responses": {
"200": {
"description": "All alert rules for this specific kapacitor are returned",
@ -871,29 +933,37 @@
}
},
"post": {
"tags": ["sources", "kapacitors", "rules"],
"tags": [
"sources",
"kapacitors",
"rules"
],
"description": "Create kapacitor alert rule",
"parameters": [{
"name": "id",
"in": "path",
"type": "string",
"description": "ID of the source",
"required": true
}, {
"name": "kapa_id",
"in": "path",
"type": "string",
"description": "ID of the kapacitor backend.",
"required": true
}, {
"name": "rule",
"in": "body",
"description": "Rule to generate alert rule",
"schema": {
"$ref": "#/definitions/Rule"
"parameters": [
{
"name": "id",
"in": "path",
"type": "string",
"description": "ID of the source",
"required": true
},
"required": true
}],
{
"name": "kapa_id",
"in": "path",
"type": "string",
"description": "ID of the kapacitor backend.",
"required": true
},
{
"name": "rule",
"in": "body",
"description": "Rule to generate alert rule",
"schema": {
"$ref": "#/definitions/Rule"
},
"required": true
}
],
"responses": {
"201": {
"description": "Successfully created new kapacitor alert rule",
@ -914,7 +984,7 @@
"$ref": "#/definitions/Error"
}
},
"422": {
"422": {
"description": "Source ID , Kapacitor ID or alert are unprocessable",
"schema": {
"$ref": "#/definitions/Error"
@ -931,26 +1001,34 @@
},
"/sources/{id}/kapacitors/{kapa_id}/rules/{rule_id}": {
"get": {
"tags": ["sources", "kapacitors", "rules"],
"parameters": [{
"name": "id",
"in": "path",
"type": "string",
"description": "ID of the source",
"required": true
}, {
"name": "kapa_id",
"in": "path",
"type": "string",
"description": "ID of the kapacitor",
"required": true
}, {
"name": "rule_id",
"in": "path",
"type": "string",
"description": "ID of the rule",
"required": true
}],
"tags": [
"sources",
"kapacitors",
"rules"
],
"parameters": [
{
"name": "id",
"in": "path",
"type": "string",
"description": "ID of the source",
"required": true
},
{
"name": "kapa_id",
"in": "path",
"type": "string",
"description": "ID of the kapacitor",
"required": true
},
{
"name": "rule_id",
"in": "path",
"type": "string",
"description": "ID of the rule",
"required": true
}
],
"summary": "Specific kapacitor alert rule",
"description": "Alerting rule for kapacitor",
"responses": {
@ -975,9 +1053,14 @@
}
},
"put": {
"tags": ["sources", "kapacitors", "rules"],
"tags": [
"sources",
"kapacitors",
"rules"
],
"summary": "Update rule alert rule configuration",
"parameters": [{
"parameters": [
{
"name": "id",
"in": "path",
"type": "string",
@ -990,7 +1073,8 @@
"type": "string",
"description": "ID of a kapacitor backend",
"required": true
}, {
},
{
"name": "rule_id",
"in": "path",
"type": "string",
@ -1029,7 +1113,11 @@
}
},
"delete": {
"tags": ["sources", "kapacitors", "rules"],
"tags": [
"sources",
"kapacitors",
"rules"
],
"parameters": [
{
"name": "id",
@ -1044,7 +1132,8 @@
"type": "string",
"description": "ID of the kapacitor",
"required": true
}, {
},
{
"name": "rule_id",
"in": "path",
"type": "string",
@ -1074,7 +1163,11 @@
},
"/sources/{id}/kapacitors/{kapa_id}/proxy": {
"get": {
"tags": ["sources", "kapacitors", "proxy"],
"tags": [
"sources",
"kapacitors",
"proxy"
],
"description": "GET to `path` of kapacitor. The response and status code from kapacitor is directly returned.",
"parameters": [
{
@ -1118,7 +1211,11 @@
}
},
"delete": {
"tags": ["sources", "kapacitors", "proxy"],
"tags": [
"sources",
"kapacitors",
"proxy"
],
"description": "DELETE to `path` of kapacitor. The response and status code from kapacitor is directly returned.",
"parameters": [
{
@ -1162,7 +1259,11 @@
}
},
"patch": {
"tags": ["sources", "kapacitors", "proxy"],
"tags": [
"sources",
"kapacitors",
"proxy"
],
"description": "PATCH body directly to configured kapacitor. The response and status code from kapacitor is directly returned.",
"parameters": [
{
@ -1215,7 +1316,11 @@
}
},
"post": {
"tags": ["sources", "kapacitors", "proxy"],
"tags": [
"sources",
"kapacitors",
"proxy"
],
"description": "POST body directly to configured kapacitor. The response and status code from kapacitor is directly returned.",
"parameters": [
{
@ -1270,7 +1375,10 @@
},
"/mappings": {
"get": {
"tags": ["layouts", "mappings"],
"tags": [
"layouts",
"mappings"
],
"summary": "Mappings between app names and measurements",
"description": "Mappings provide a means to alias measurement names found within a telegraf database and application layouts found within Chronograf\n",
"responses": {
@ -1291,7 +1399,9 @@
},
"/layouts": {
"get": {
"tags": ["layouts"],
"tags": [
"layouts"
],
"summary": "Pre-configured layouts",
"parameters": [
{
@ -1334,7 +1444,9 @@
}
},
"post": {
"tags": ["layouts"],
"tags": [
"layouts"
],
"summary": "Create new layout",
"parameters": [
{
@ -1371,7 +1483,9 @@
},
"/layouts/{id}": {
"get": {
"tags": ["layouts"],
"tags": [
"layouts"
],
"parameters": [
{
"name": "id",
@ -1405,7 +1519,9 @@
}
},
"delete": {
"tags": ["layouts"],
"tags": [
"layouts"
],
"parameters": [
{
"name": "id",
@ -1435,7 +1551,9 @@
}
},
"put": {
"tags": ["layouts"],
"tags": [
"layouts"
],
"summary": "Replace layout configuration.",
"parameters": [
{
@ -1552,9 +1670,9 @@
"description": "Entire response from the kapacitor backend.",
"type": "object"
},
"Rules": {
"Rules": {
"type": "object",
"required": [
"required": [
"rules"
],
"properties": {
@ -1570,85 +1688,83 @@
"type": "object",
"required": [
"every",
"trigger"
"trigger"
],
"properties": {
"id": {
"type": "string",
"description": "ID for this rule; the ID is shared with kapacitor"
},
"name": {
"type": "string",
"description": "User facing name of the alerting rule"
},
"every" : {
"type": "string",
"description": "Golang duration string specifying how often the alert condition is checked"
},
"alerts": {
"type": "array",
"description": "Array of alerting services to warn if the alert is triggered",
"items": {
"id": {
"type": "string",
"description": "ID for this rule; the ID is shared with kapacitor"
},
"name": {
"type": "string",
"description": "User facing name of the alerting rule"
},
"every": {
"type": "string",
"description": "Golang duration string specifying how often the alert condition is checked"
},
"alerts": {
"type": "array",
"description": "Array of alerting services to warn if the alert is triggered",
"items": {
"type": "string",
"enum": [
"hipchat",
"opsgenie",
"pagerduty",
"victorops",
"smtp",
"email",
"sensu",
"slack",
"talk",
"telegram"
]
"enum": [
"hipchat",
"opsgenie",
"pagerduty",
"victorops",
"smtp",
"email",
"sensu",
"slack",
"talk",
"telegram"
]
}
},
"message": {
"type": "string",
"description": "Message to send when alert occurs."
},
"trigger": {
"type": "string",
"description": "Trigger defines the alerting structure; deadman alert if no data are received for the specified time range; relative alert if the data change relative to the data in a different time range; threshold alert if the data cross a boundary",
"enum": [
},
"message": {
"type": "string",
"description": "Message to send when alert occurs."
},
"trigger": {
"type": "string",
"description": "Trigger defines the alerting structure; deadman alert if no data are received for the specified time range; relative alert if the data change relative to the data in a different time range; threshold alert if the data cross a boundary",
"enum": [
"deadman",
"relative",
"threshold"
"threshold"
]
},
"tickscript": {
"type": "string",
"description": "TICKscript representing this rule"
},
},
"tickscript": {
"type": "string",
"description": "TICKscript representing this rule"
},
"links": {
"type": "object",
"required": [
"self",
"kapacitor"
],
"properties": {
"self": {
"description": "Self link pointing to this rule resource",
"type": "string",
"format": "uri"
},
"kapacitor": {
"description": "Link pointing to the kapacitor proxy for this rule including the path query parameter.",
"type": "string",
"format": "uri"
},
"output": {
"description": "Link pointing to the kapacitor httpOut node of the tickscript; includes the path query argument",
"type": "string",
"format": "uri"
}
}
"type": "object",
"required": [
"self",
"kapacitor"
],
"properties": {
"self": {
"description": "Self link pointing to this rule resource",
"type": "string",
"format": "uri"
},
"kapacitor": {
"description": "Link pointing to the kapacitor proxy for this rule including the path query parameter.",
"type": "string",
"format": "uri"
},
"output": {
"description": "Link pointing to the kapacitor httpOut node of the tickscript; includes the path query argument",
"type": "string",
"format": "uri"
}
}
}
}
},
"Sources": {
"type": "object",
"required": [
@ -1909,18 +2025,18 @@
"Cell": {
"type": "object",
"required": [
"i",
"i",
"x",
"y",
"w",
"h"
],
"properties": {
"i": {
"description": "Unique ID of Cell",
"type": "string",
"format": "uuid4"
},
"i": {
"description": "Unique ID of Cell",
"type": "string",
"format": "uuid4"
},
"x": {
"description": "X-coordinate of Cell in the Layout",
"type": "integer",
@ -1947,22 +2063,7 @@
"items": {
"$ref": "#/definitions/LayoutQuery"
}
},
"ylabels": {
"description": "Optional Y-axis user-facing label",
"type": "array",
"items": {
"type": "string"
}
},
"yranges": {
"description": "Optional default range of the Y-axis; Must come in pairs.",
"type": "array",
"items": {
"type": "integer",
"format": "int64"
}
}
}
}
},
"LayoutQuery": {
@ -1971,6 +2072,30 @@
"query"
],
"properties": {
"label": {
"description": "Optional Y-axis user-facing label for this query",
"type": "string"
},
"range": {
"description": "Optional default range of the Y-axis",
"type": "object",
"required": [
"upper",
"lower"
],
"properties": {
"upper": {
"description": "Upper bound of the display range of the Y-axis",
"type": "integer",
"format": "int64"
},
"lower": {
"description": "Lower bound of the display range of the Y-axis",
"type": "integer",
"format": "int64"
}
}
},
"query": {
"type": "string"
},
@ -1998,7 +2123,7 @@
"type": "string",
"format": "url"
},
"me": {
"me": {
"description": "Location of the me endpoint.",
"type": "string",
"format": "url"
@ -2062,4 +2187,4 @@
}
}
}
}
}