Logs Panel: Generate types from schema (#63716)

This commit is contained in:
Alex Khomenko 2023-02-27 13:56:35 +02:00 committed by GitHub
parent d56896cf72
commit 5ad074ff2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 129 additions and 32 deletions

View File

@ -0,0 +1,33 @@
---
keywords:
- grafana
- schema
title: LogsPanelCfg kind
---
> Both documentation generation and kinds schemas are in active development and subject to change without prior notice.
## LogsPanelCfg
#### Maturity: [experimental](../../../maturity/#experimental)
#### Version: 0.0
| Property | Type | Required | Description |
|----------------|-------------------------|----------|-------------|
| `PanelOptions` | [object](#paneloptions) | **Yes** | |
### PanelOptions
| Property | Type | Required | Description |
|----------------------|---------|----------|---------------------------------------------------------------|
| `dedupStrategy` | string | **Yes** | Possible values are: `none`, `exact`, `numbers`, `signature`. |
| `enableLogDetails` | boolean | **Yes** | |
| `prettifyLogMessage` | boolean | **Yes** | |
| `showCommonLabels` | boolean | **Yes** | |
| `showLabels` | boolean | **Yes** | |
| `showTime` | boolean | **Yes** | |
| `sortOrder` | string | **Yes** | Possible values are: `Descending`, `Ascending`. |
| `wrapLogMessage` | boolean | **Yes** | |

View File

@ -5,6 +5,7 @@ import { DataFrame } from './dataFrame';
import { DataQueryRequest, DataQueryResponse } from './datasource';
import { DataQuery } from './query';
import { AbsoluteTimeRange } from './time';
export { LogsDedupStrategy, LogsSortOrder } from '@grafana/schema';
/**
* Mapping of log level abbreviation to canonical log level.
@ -39,11 +40,6 @@ export enum LogsMetaKind {
Error,
}
export enum LogsSortOrder {
Descending = 'Descending',
Ascending = 'Ascending',
}
export interface LogsMetaItem {
label: string;
value: string | number | Labels;
@ -106,13 +102,6 @@ export interface LogLabelStatsModel {
value: string;
}
export enum LogsDedupStrategy {
none = 'none',
exact = 'exact',
numbers = 'numbers',
signature = 'signature',
}
/** @deprecated will be removed in the next major version */
export interface LogsParser {
/**

View File

@ -109,6 +109,11 @@ export enum FrameGeometrySourceMode {
Lookup = 'lookup',
}
export enum LogsSortOrder {
Ascending = 'Ascending',
Descending = 'Descending',
}
/**
* TODO docs
*/
@ -697,6 +702,13 @@ export interface FrameGeometrySource {
wkt?: string;
}
export enum LogsDedupStrategy {
exact = 'exact',
none = 'none',
numbers = 'numbers',
signature = 'signature',
}
export interface Labels {}
/**

View File

@ -0,0 +1,4 @@
package common
LogsSortOrder: "Descending" | "Ascending" @cuetsy(kind="enum")
LogsDedupStrategy: "none" | "exact" | "numbers" | "signature" @cuetsy(kind="enum",memberNames="none|exact|numbers|signature")

View File

@ -892,7 +892,9 @@
},
"logspanelcfg": {
"category": "composable",
"codeowners": [],
"codeowners": [
"grafana/observability-logs"
],
"currentVersion": [
0,
0
@ -900,13 +902,13 @@
"grafanaMaturityCount": 0,
"lineageIsGroup": true,
"links": {
"docs": "n/a",
"docs": "https://grafana.com/docs/grafana/next/developers/kinds/composable/logspanelcfg/schema-reference",
"go": "n/a",
"schema": "n/a",
"ts": "n/a"
"schema": "https://github.com/grafana/grafana/tree/main/public/app/plugins/panel/logs/panelcfg.cue",
"ts": "https://github.com/grafana/grafana/tree/main/public/app/plugins/panel/logs/panelcfg.gen.ts"
},
"machineName": "logspanelcfg",
"maturity": "planned",
"maturity": "experimental",
"name": "LogsPanelCfg",
"pluralMachineName": "logspanelcfgs",
"pluralName": "LogsPanelCfgs",
@ -1994,6 +1996,7 @@
"geomappanelcfg",
"histogrampanelcfg",
"librarypanel",
"logspanelcfg",
"lokidataquery",
"newspanelcfg",
"nodegraphpanelcfg",
@ -2008,7 +2011,7 @@
"textpanelcfg",
"xychartpanelcfg"
],
"count": 24
"count": 25
},
"mature": {
"name": "mature",
@ -2056,7 +2059,6 @@
"jaegerdataquery",
"jaegerdatasourcecfg",
"livepanelcfg",
"logspanelcfg",
"lokidatasourcecfg",
"microsoftsqlserverdataquery",
"microsoftsqlserverdatasourcecfg",
@ -2080,7 +2082,7 @@
"zipkindataquery",
"zipkindatasourcecfg"
],
"count": 47
"count": 46
},
"stable": {
"name": "stable",

View File

@ -0,0 +1,44 @@
// Copyright 2023 Grafana Labs
//
// 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 grafanaplugin
import (
"github.com/grafana/grafana/packages/grafana-schema/src/common"
)
composableKinds: PanelCfg: {
maturity: "experimental"
lineage: {
seqs: [
{
schemas: [
{
PanelOptions: {
showLabels: bool
showCommonLabels: bool
showTime: bool
wrapLogMessage: bool
prettifyLogMessage: bool
enableLogDetails: bool
sortOrder: common.LogsSortOrder
dedupStrategy: common.LogsDedupStrategy
} @cuetsy(kind="interface")
},
]
},
]
}
}

View File

@ -0,0 +1,24 @@
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
//
// Generated by:
// public/app/plugins/gen.go
// Using jennies:
// TSTypesJenny
// PluginTSTypesJenny
//
// Run 'make gen-cue' from repository root to regenerate.
import * as common from '@grafana/schema';
export const PanelCfgModelVersion = Object.freeze([0, 0]);
export interface PanelOptions {
dedupStrategy: common.LogsDedupStrategy;
enableLogDetails: boolean;
prettifyLogMessage: boolean;
showCommonLabels: boolean;
showLabels: boolean;
showTime: boolean;
sortOrder: common.LogsSortOrder;
wrapLogMessage: boolean;
}

View File

@ -1,12 +1 @@
import { LogsSortOrder, LogsDedupStrategy } from '@grafana/data';
export interface Options {
showLabels: boolean;
showCommonLabels: boolean;
showTime: boolean;
wrapLogMessage: boolean;
prettifyLogMessage: boolean;
enableLogDetails: boolean;
sortOrder: LogsSortOrder;
dedupStrategy: LogsDedupStrategy;
}
export { PanelOptions as Options } from './panelcfg.gen';