Skip to content
Open
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
18 changes: 18 additions & 0 deletions panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
RowType
BarGaugeType
HeatmapType
LogsType
)

const MixedSource = "-- Mixed --"
Expand All @@ -59,6 +60,7 @@ type (
*AlertlistPanel
*BarGaugePanel
*HeatmapPanel
*LogsPanel
*CustomPanel
}
panelType int8
Expand Down Expand Up @@ -173,6 +175,10 @@ type (
} `json:"threshold"`
} `json:"defaults"`
}
LogsPanel struct {
CommonPanel
Targets []Target `json:"targets,omitempty"`
}
Options struct {
Orientation string `json:"orientation"`
TextMode string `json:"textMode"`
Expand Down Expand Up @@ -973,6 +979,12 @@ func (p *Panel) UnmarshalJSON(b []byte) (err error) {
if err = json.Unmarshal(b, &rowpanel); err == nil {
p.RowPanel = &rowpanel
}
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 @@ -1052,6 +1064,12 @@ func (p *Panel) MarshalJSON() ([]byte, error) {
HeatmapPanel
}{p.CommonPanel, *p.HeatmapPanel}
return json.Marshal(outHeatmap)
case LogsType:
var outLogs = struct {
CommonPanel
LogsPanel
}{p.CommonPanel, *p.LogsPanel}
return json.Marshal(outLogs)
case CustomType:
var outCustom = struct {
CommonPanel
Expand Down