-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CUE files for panel plugins (#11)
Signed-off-by: Antoine THEBAUD <[email protected]> Co-authored-by: Antoine THEBAUD <[email protected]>
- Loading branch information
1 parent
9e95603
commit b2c69b5
Showing
95 changed files
with
2,863 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2023 The Perses Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package model | ||
|
||
import ( | ||
"github.com/perses/perses/cue/schemas/common" | ||
) | ||
|
||
kind: "BarChart" | ||
spec: close({ | ||
calculation: common.#calculation | ||
format?: common.#format | ||
sort?: "asc" | "desc" | ||
mode?: "value" | "percentage" | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"kind": "BarChart", | ||
"spec": { | ||
"calculation": "last-number", | ||
"format": { | ||
"unit": "percent", | ||
"decimalPlaces": 2 | ||
}, | ||
"sort": "desc", | ||
"mode": "value" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
if #panel.type != _|_ if #panel.type == "bargauge" { | ||
kind: "BarChart" | ||
spec: { | ||
#calcName: *"\(#panel.options.reduceOptions.calcs[0])" | null // only consider [0] here as Perses's BarChart doesn't support individual calcs | ||
calculation: [// switch | ||
if #mapping.calc[#calcName] != _|_ {#mapping.calc[#calcName]}, | ||
{#defaultCalc}, | ||
][0] | ||
|
||
#unitPath: *"\(#panel.fieldConfig.defaults.unit)" | null | ||
if #unitPath != null if #mapping.unit[#unitPath] != _|_ { | ||
format: { | ||
unit: #mapping.unit[#unitPath] | ||
} | ||
} | ||
#decimal: *(#panel.fieldConfig.defaults.decimal) | null | ||
if #decimal != null { | ||
format: { | ||
decimalPlaces: #decimal | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module: "github.com/perses/plugins/barchart@v0" | ||
language: { | ||
version: "v0.10.0" | ||
} |
16 changes: 16 additions & 0 deletions
16
BarChart/cue.mod/pkg/github.com/perses/perses/cue/schemas/common/calculation.cue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2023 The Perses Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package common | ||
|
||
#calculation: "first" | *"last" | "first-number" | "last-number" | "mean" | "sum" | "min" | "max" |
44 changes: 44 additions & 0 deletions
44
BarChart/cue.mod/pkg/github.com/perses/perses/cue/schemas/common/format.cue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2023 The Perses Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package common | ||
|
||
#format: #timeFormat | #percentFormat | #decimalFormat | #bytesFormat | #throughputFormat | ||
|
||
#timeFormat: { | ||
unit: "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | "years" | ||
decimalPlaces?: number | ||
} | ||
|
||
#percentFormat: { | ||
unit: "percent" | "percent-decimal" | ||
decimalPlaces?: number | ||
} | ||
|
||
#decimalFormat: { | ||
unit: "decimal" | ||
decimalPlaces?: number | ||
shortValues?: bool | ||
} | ||
|
||
#bytesFormat: { | ||
unit: "bytes" | ||
decimalPlaces?: number | ||
shortValues?: bool | ||
} | ||
|
||
#throughputFormat: { | ||
unit: "bits/sec" | "bytes/sec" | "counts/sec" | "events/sec" | "messages/sec" | "ops/sec" | "packets/sec" | "reads/sec" | "records/sec" | "requests/sec" | "rows/sec" | "writes/sec" | ||
decimalPlaces?: number | ||
shortValues?: bool | ||
} |
40 changes: 40 additions & 0 deletions
40
BarChart/cue.mod/pkg/github.com/perses/perses/cue/schemas/common/proxy/http.cue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2023 The Perses Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package proxy | ||
|
||
import ( | ||
"github.com/perses/perses/cue/schemas/common" | ||
) | ||
|
||
#HTTPAllowedEndpoint: { | ||
endpointPattern: string | ||
method: "POST" | "PUT" | "PATCH" | "GET" | "DELETE" | ||
} | ||
|
||
#HTTPProxy: { | ||
kind: "HTTPProxy" | ||
spec: { | ||
// url is the url of the datasource. It is not the url of the proxy. | ||
// The Perses server is the proxy, so it needs to know where to redirect the request. | ||
url: common.#url | ||
// allowedEndpoints is a list of tuples of http methods and http endpoints that will be accessible. | ||
// Leave it empty if you don't want to restrict the access to the datasource. | ||
allowedEndpoints?: [...#HTTPAllowedEndpoint] | ||
// headers can be used to provide additional headers that need to be forwarded when requesting the datasource | ||
headers?: {[string]: string} | ||
// secret is the name of the secret that should be used for the proxy or discovery configuration | ||
// It will contain any sensitive information such as password, token, certificate. | ||
secret?: string | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
BarChart/cue.mod/pkg/github.com/perses/perses/cue/schemas/common/threshold.cue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2023 The Perses Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package common | ||
|
||
#stepOption: { | ||
value: number | ||
color?: string | ||
name?: string | ||
} | ||
|
||
#thresholds: { | ||
mode?: "percent" | "absolute" | ||
defaultColor?: string | ||
steps?: [...#stepOption] | ||
} |
16 changes: 16 additions & 0 deletions
16
BarChart/cue.mod/pkg/github.com/perses/perses/cue/schemas/common/url.cue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2023 The Perses Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package common | ||
|
||
#url: =~"^https?:\/\/[^\\s\/$.?#].[^\\s]*$" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2023 The Perses Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package model | ||
|
||
import ( | ||
"github.com/perses/perses/cue/schemas/common" | ||
) | ||
|
||
kind: "GaugeChart" | ||
spec: close({ | ||
calculation: common.#calculation | ||
format?: common.#format | ||
thresholds?: common.#thresholds | ||
max?: number // determines end value of last threshold color segment when unit is not a percent | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"kind": "GaugeChart", | ||
"spec": { | ||
"calculation": "last-number", | ||
"format": { | ||
"unit": "percent", | ||
"decimalPlaces": 2 | ||
}, | ||
"thresholds": { | ||
"steps": [ | ||
{ | ||
"value": 85 | ||
}, | ||
{ | ||
"value": 95 | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
if #panel.type != _|_ if #panel.type == "gauge" { | ||
kind: "GaugeChart" | ||
spec: { | ||
#calcName: *"\(#panel.options.reduceOptions.calcs[0])" | null // only consider [0] here as Perses's GaugeChart doesn't support individual calcs | ||
calculation: [// switch | ||
if #mapping.calc[#calcName] != _|_ {#mapping.calc[#calcName]}, | ||
#defaultCalc, | ||
][0] | ||
|
||
#unitPath: *"\(#panel.fieldConfig.defaults.unit)" | null | ||
if #unitPath != null if #mapping.unit[#unitPath] != _|_ { | ||
format: { | ||
unit: #mapping.unit[#unitPath] | ||
} | ||
} | ||
#decimal: *(#panel.fieldConfig.defaults.decimal) | null | ||
if #decimal != null { | ||
format: { | ||
decimalPlaces: #decimal | ||
} | ||
} | ||
|
||
if #panel.fieldConfig.defaults.thresholds != _|_ if #panel.fieldConfig.defaults.thresholds.steps != _|_ { | ||
thresholds: { | ||
// defaultColor: TODO how to fill this one? | ||
steps: [for _, step in #panel.fieldConfig.defaults.thresholds.steps if step.value != _|_ { | ||
value: [// switch | ||
if step.value == null {0}, | ||
step.value, | ||
][0] | ||
color: step.color | ||
}] | ||
} | ||
} | ||
if #panel.fieldConfig.defaults.max != _|_ { | ||
max: #panel.fieldConfig.defaults.max | ||
} | ||
} | ||
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module: "github.com/perses/plugins/gaugechart@v0" | ||
language: { | ||
version: "v0.10.0" | ||
} |
16 changes: 16 additions & 0 deletions
16
GaugeChart/cue.mod/pkg/github.com/perses/perses/cue/schemas/common/calculation.cue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2023 The Perses Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package common | ||
|
||
#calculation: "first" | *"last" | "first-number" | "last-number" | "mean" | "sum" | "min" | "max" |
44 changes: 44 additions & 0 deletions
44
GaugeChart/cue.mod/pkg/github.com/perses/perses/cue/schemas/common/format.cue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2023 The Perses Authors | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package common | ||
|
||
#format: #timeFormat | #percentFormat | #decimalFormat | #bytesFormat | #throughputFormat | ||
|
||
#timeFormat: { | ||
unit: "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | "years" | ||
decimalPlaces?: number | ||
} | ||
|
||
#percentFormat: { | ||
unit: "percent" | "percent-decimal" | ||
decimalPlaces?: number | ||
} | ||
|
||
#decimalFormat: { | ||
unit: "decimal" | ||
decimalPlaces?: number | ||
shortValues?: bool | ||
} | ||
|
||
#bytesFormat: { | ||
unit: "bytes" | ||
decimalPlaces?: number | ||
shortValues?: bool | ||
} | ||
|
||
#throughputFormat: { | ||
unit: "bits/sec" | "bytes/sec" | "counts/sec" | "events/sec" | "messages/sec" | "ops/sec" | "packets/sec" | "reads/sec" | "records/sec" | "requests/sec" | "rows/sec" | "writes/sec" | ||
decimalPlaces?: number | ||
shortValues?: bool | ||
} |
Oops, something went wrong.