diff --git a/logstable/schemas/migrate/migrate.cue b/logstable/schemas/migrate/migrate.cue new file mode 100644 index 000000000..75d0678ba --- /dev/null +++ b/logstable/schemas/migrate/migrate.cue @@ -0,0 +1,29 @@ +// Copyright 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 migrate + +#grafanaType: "logs" +#panel: _ + +kind: "LogsTable" +spec: { + if #panel.options.wrapLogMessage != _|_ { + allowWrap: #panel.options.wrapLogMessage + } + if #panel.options.showTime != _|_ { + showTime: #panel.options.showTime + } + #enableLogDetails: *#panel.options.enableLogDetails | true + enableDetails: #enableLogDetails +} diff --git a/logstable/schemas/migrate/tests/basic/expected.json b/logstable/schemas/migrate/tests/basic/expected.json new file mode 100644 index 000000000..53ecd2480 --- /dev/null +++ b/logstable/schemas/migrate/tests/basic/expected.json @@ -0,0 +1,8 @@ +{ + "kind": "LogsTable", + "spec": { + "allowWrap": true, + "enableDetails": true, + "showTime": true + } +} diff --git a/logstable/schemas/migrate/tests/basic/input.json b/logstable/schemas/migrate/tests/basic/input.json new file mode 100644 index 000000000..96918fcf7 --- /dev/null +++ b/logstable/schemas/migrate/tests/basic/input.json @@ -0,0 +1,22 @@ +{ + "datasource": { + "uid": "loki" + }, + "options": { + "showLabels": false, + "showTime": true, + "sortOrder": "Descending", + "wrapLogMessage": true + }, + "targets": [ + { + "datasource": { + "uid": "loki" + }, + "expr": "{pod_name=~\"$pod\"} |~ \"$search\"", + "refId": "A" + } + ], + "title": "Logs Panel", + "type": "logs" +} diff --git a/logstable/schemas/migrate/tests/details-disabled/expected.json b/logstable/schemas/migrate/tests/details-disabled/expected.json new file mode 100644 index 000000000..24367ef28 --- /dev/null +++ b/logstable/schemas/migrate/tests/details-disabled/expected.json @@ -0,0 +1,8 @@ +{ + "kind": "LogsTable", + "spec": { + "allowWrap": false, + "enableDetails": false, + "showTime": false + } +} diff --git a/logstable/schemas/migrate/tests/details-disabled/input.json b/logstable/schemas/migrate/tests/details-disabled/input.json new file mode 100644 index 000000000..baf4439d6 --- /dev/null +++ b/logstable/schemas/migrate/tests/details-disabled/input.json @@ -0,0 +1,23 @@ +{ + "datasource": { + "uid": "loki" + }, + "options": { + "enableLogDetails": false, + "showLabels": false, + "showTime": false, + "sortOrder": "Descending", + "wrapLogMessage": false + }, + "targets": [ + { + "datasource": { + "uid": "loki" + }, + "expr": "{job=\"nginx\"}", + "refId": "A" + } + ], + "title": "Logs", + "type": "logs" +}