Skip to content

Commit

Permalink
Support Loki logs typed panel
Browse files Browse the repository at this point in the history
Added another panel type - Loki logs
  • Loading branch information
zzxwill committed Aug 19, 2021
1 parent 671d407 commit f9bb712
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const (
GaugeType
HeatmapType
TableOldType
LogsType
)

const MixedSource = "-- Mixed --"
Expand All @@ -63,6 +64,7 @@ type (
*GaugePanel
*HeatmapPanel
*TableOldPanel
*LogsPanel
*CustomPanel
}
panelType int8
Expand Down Expand Up @@ -183,6 +185,11 @@ type (
Styles []ColumnStyle `json:"styles"`
}
TableOldPanel struct {
CommonPanel
Targets []Target `json:"targets,omitempty"`
Styles []ColumnStyle `json:"styles"`
}
LogsPanel struct {
CommonPanel
Targets []Target `json:"targets,omitempty"`
}
Expand Down Expand Up @@ -998,6 +1005,12 @@ func (p *Panel) UnmarshalJSON(b []byte) (err error) {
if err = json.Unmarshal(b, &tableOldPanel); err == nil {
p.TableOldPanel = &tableOldPanel
}
case "logs":
var logsPanel LogsPanel
p.OfType = LogsType
if err = json.Unmarshal(b, &logsPanel); err == nil {
p.LogsPanel = &logsPanel
}
default:
var custom = make(CustomPanel)
p.OfType = CustomType
Expand Down Expand Up @@ -1089,6 +1102,12 @@ func (p *Panel) MarshalJSON() ([]byte, error) {
TableOldPanel
}{p.CommonPanel, *p.TableOldPanel}
return json.Marshal(outTableOld)
case LogsType:
var outLogs = struct {
CommonPanel
LogsPanel
}{p.CommonPanel, *p.LogsPanel}
return json.Marshal(outLogs)
case CustomType:
var outCustom = struct {
CommonPanel
Expand Down

0 comments on commit f9bb712

Please sign in to comment.