Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/components @perses/frontend-maintainers
/cue @AntoineThebaud
/cue-test @AntoineThebaud
/dashboards @perses/frontend-maintainers
/explore @perses/frontend-maintainers
/plugin-system @perses/frontend-maintainers
53 changes: 53 additions & 0 deletions .github/workflows/cue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: cue
on:
push:
branches:
- main
- release/*
- snapshot/*
tags:
- v*
pull_request:
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.ref_name != 'main' }}

jobs:
validate-schemas:
name: validate CUE schemas
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v6
- uses: perses/[email protected]
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_go: true
enable_cue: true
cue_version: "v0.15.1"
- name: check that CUE schemas evaluate correctly
run: make cue-eval
- name: run the unit tests for CUE schemas
run: make cue-test

publish-module:
name: "publish CUE module to Central Registry"
needs: "validate-schemas"
runs-on: ubuntu-latest
if: ${{ github.event.release.tag_name }}
steps:
- name: Checkout
uses: actions/checkout@v6
- uses: perses/[email protected]
- uses: ./.github/perses-ci/actions/setup_environment
with:
enable_go: true
enable_cue: true
cue_version: "v0.15.1"
- name: Login to Central Registry # to allow publishing the module
run: cue login --token=${{ secrets.CUE_REG_TOKEN }}
- name: Publish the module
run: cue mod publish ${{ github.ref_name }}
working-directory: cue
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2025 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.

GO ?= go
CUE ?= cue

.PHONY: cue-eval
cue-eval:
@echo ">> Check that CUE schemas evaluate correctly"
cd cue && $(CUE) eval ./...

.PHONY: cue-test
cue-test:
@echo ">> Run the unit tests for CUE schemas"
$(GO) run ./scripts/test-cue/test-cue.go
19 changes: 19 additions & 0 deletions cue-test/common/format.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2025 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

myFormat: #format & {
decimalPlaces: 0
shortValues: false
}
28 changes: 28 additions & 0 deletions cue-test/common/transform.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2025 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

myJoinByColumnValueTransform: #joinByColumnValueTransform & { spec: columns: ["job", "instance"] }

myMergeColumnsTransform: #mergeColumnsTransform & {
spec: {
columns: ["job", "instance"]
name: "job-instance"
disabled: true
}
}

myMergeIndexedColumnsTransform: #mergeIndexedColumnsTransform & { spec: column: "instance" }

mergeSeries: #mergeSeries & { spec: disabled: false }
17 changes: 17 additions & 0 deletions cue-test/common/url.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2025 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

test1: #url & "http://localhost:9090"
test2: #url & "https://localhost:9090"
20 changes: 20 additions & 0 deletions cue/common/calculation.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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: #calculationAggregation // kind-of default value defined for retro-compatibility. Please rather use below types directly for new plugins.

#calculationAggregation: "first" | *"last" | "first-number" | "last-number" | "mean" | "sum" | "min" | "max"

#calculationComparison: "abs" | "relative"
21 changes: 21 additions & 0 deletions cue/common/datasource.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2025 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

#datasourceSelector: {
datasource?: =~#variableSyntaxRegex | {
kind: string
name?: string
}
}
79 changes: 79 additions & 0 deletions cue/common/format.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// 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: #simpleFormat | #floatFormat | #shortenableFormat

#simpleFormat: {
unit?: #dateFormat.unit
}

#floatFormat: {
unit?: #timeFormat.unit | #percentFormat.unit | #currencyFormat.unit | #temperatureFormat.unit
decimalPlaces?: number
}

#shortenableFormat: {
unit?: #decimalFormat.unit | #bitsFormat.unit | #bytesFormat.unit | #throughputFormat.unit
decimalPlaces?: number
shortValues?: bool
}

#timeFormat: {
unit: "nanoseconds" | "microseconds" | "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "weeks" | "months" | "years"
decimalPlaces?: number
}

#percentFormat: {
unit: "percent" | "percent-decimal"
decimalPlaces?: number
}

#decimalFormat: {
unit: "decimal"
decimalPlaces?: number
shortValues?: bool
}

#bitsFormat: {
unit: "bits" | "decbits"
decimalPlaces?: number
shortValues?: bool
}

#bytesFormat: {
unit: "bytes" | "decbytes"
decimalPlaces?: number
shortValues?: bool
}

#throughputFormat: {
unit: "bits/sec" | "decbits/sec" | "bytes/sec" | "decbytes/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
}

#currencyFormat: {
unit: "aud" | "cad" | "chf" | "cny" | "eur" | "gbp" | "hkd" | "inr" | "jpy" | "krw" | "nok" | "nzd" | "sek" | "sgd" | "usd"
decimalPlaces?: number
}

#temperatureFormat: {
unit: "celsius" | "fahrenheit"
decimalPlaces?: number
}

#dateFormat: {
unit: "datetime-iso" | "datetime-us" | "datetime-local" | "date-iso" | "date-us" | "date-local" | "time-local" | "time-iso" | "time-us" | "relative-time" | "unix-timestamp" | "unix-timestamp-ms"
}
25 changes: 25 additions & 0 deletions cue/common/legend.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2025 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

#legend: {
position: "bottom" | "right"
mode?: "list" | "table"
size?: "small" | "medium"
}

#legendWithValues: {
#legend
values?: [...#calculation]
}
58 changes: 58 additions & 0 deletions cue/common/mappings.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2024 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

import (
"strings"
)

#valueCondition: {
kind: "Value"
spec: {
value: strings.MinRunes(1)
result: #mappingResult
}
}

#rangeCondition: {
kind: "Range"
spec: {
from?: number
to?: number
result: #mappingResult
}
}

#regexCondition: {
kind: "Regex"
spec: {
pattern: strings.MinRunes(1)
result: #mappingResult
}
}

#miscCondition: {
kind: "Misc"
spec: {
value: "empty" | "null" | "NaN" | "true" | "false"
result: #mappingResult
}
}

#mappingResult: {
value: string
color?: =~"^#(?:[0-9a-fA-F]{3}){1,2}$"
}

#mappings: #valueCondition | #rangeCondition | #regexCondition | #miscCondition
16 changes: 16 additions & 0 deletions cue/common/metricLabel.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2025 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

#metricLabel: string
Loading