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
172 changes: 171 additions & 1 deletion contrib/dashboards/dashboard_details.json
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "prometheus",
"datasource": "loki",
"fill": 1,
"fillGradient": 0,
"gridPos": {
Expand Down Expand Up @@ -1126,6 +1126,176 @@
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "sum by (srcK8S_Namespace) (sum_over_time({job=\"flowlogs-pipeline\"} | json | unwrap bytes [1m]))",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "",
"refId": "A"
}
],
"thresholds": [ ],
"timeFrom": null,
"timeShift": null,
"title": "Bandwidth per source namespace",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": [ ]
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
]
},
{
"aliasColors": { },
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "loki",
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 20,
"w": 25,
"x": 0,
"y": 0
},
"id": 16,
"legend": {
"alignAsTable": false,
"avg": false,
"current": false,
"max": false,
"min": false,
"rightSide": false,
"show": true,
"sideWidth": null,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [ ],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"repeat": null,
"seriesOverrides": [ ],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "rate({job=\"flowlogs-pipeline\"}[60s])",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "",
"refId": "A"
}
],
"thresholds": [ ],
"timeFrom": null,
"timeShift": null,
"title": "Loki logs rate",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": [ ]
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
]
},
{
"aliasColors": { },
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "prometheus",
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 20,
"w": 25,
"x": 0,
"y": 0
},
"id": 17,
"legend": {
"alignAsTable": false,
"avg": false,
"current": false,
"max": false,
"min": false,
"rightSide": false,
"show": true,
"sideWidth": null,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [ ],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"repeat": null,
"seriesOverrides": [ ],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "topk(10,rate(flp_service_count[1m]))",
Expand Down
32 changes: 32 additions & 0 deletions contrib/dashboards/jsonnet/dashboard_details.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,38 @@ dashboard.new(
h: 20,
}
)
.addPanel(
graphPanel.new(
datasource='loki',
title="Bandwidth per source namespace",
)
.addTarget(
prometheus.target(
expr='sum by (srcK8S_Namespace) (sum_over_time({job="flowlogs-pipeline"} | json | unwrap bytes [1m]))',
)
), gridPos={
x: 0,
y: 0,
w: 25,
h: 20,
}
)
.addPanel(
graphPanel.new(
datasource='loki',
title="Loki logs rate",
)
.addTarget(
prometheus.target(
expr='rate({job="flowlogs-pipeline"}[60s])',
)
), gridPos={
x: 0,
y: 0,
w: 25,
h: 20,
}
)
.addPanel(
graphPanel.new(
datasource='prometheus',
Expand Down
6 changes: 5 additions & 1 deletion docs/confGenerator.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,15 @@ For `Histogram`, use `recent_raw_values`. <br>
Prometheus will add labels to the metric based on the (9.6) fields. <br>

(10) next, using grafana to visualize the metric with name from (9.2) including the
prefix and using the prometheus expression from (10.1).
prefix and using the expression from (10.1).
Grafana will visualize the metric as (10.2) and place the panel inside
a dashboard named (10.3) as defined in `config.yaml`.
The title for the panel will be (10.4)

The type field for (10.2) can be one of:
"graphPanel", "singleStat", "barGauge", "heatmap" to use prometheus datasource and visualize accordingly or,
"lokiGraphPanel" to use loki datasource and visualize accordingly

> [connection_rate_per_dest_subnet.yaml](../network_definitions/connection_rate_per_dest_subnet.yaml) is an
> example for a network_definition file in which the metric is defined to hold counts
> for the number of connections per subnet and the visualization is defined to show
Expand Down
20 changes: 20 additions & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,26 @@ and the transformation to generate the exported metric.
|||


### loki bandwidth per namespace
| **Description** | This metric observes the bandwidth per namespace (from Loki) |
|:---|:---|
| **Details** | Sum bytes for all traffic per source namespace |
| **Usage** | Evaluate network usage breakdown per source namespace |
| **Labels** | loki, graph, rate, namespace |
| **Visualized as** | "Bandwidth per source namespace" on dashboard `details` |
|||


### loki logs per sec
| **Description** | This metric observes the number of loki logs |
|:---|:---|
| **Details** | Rate of loki logs per sec |
| **Usage** | Evaluate loki service usage |
| **Labels** | loki, graph, rate |
| **Visualized as** | "Loki logs rate" on dashboard `details` |
|||


### network services count
| **Description** | This metric observes network services rate (total) |
|:---|:---|
Expand Down
20 changes: 20 additions & 0 deletions network_definitions/loki_bandwidth_per_namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#flp_confgen
description:
This metric observes the bandwidth per namespace (from Loki)
details:
Sum bytes for all traffic per source namespace
usage:
Evaluate network usage breakdown per source namespace
labels:
- loki
- graph
- rate
- namespace
visualization:
type: grafana
grafana:
- expr: 'sum by (srcK8S_Namespace) (sum_over_time({job="flowlogs-pipeline"} | json | unwrap bytes [1m]))'
type: lokiGraphPanel
dashboard: details
title:
Bandwidth per source namespace
19 changes: 19 additions & 0 deletions network_definitions/loki_logs_per_sec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#flp_confgen
description:
This metric observes the number of loki logs
details:
Rate of loki logs per sec
usage:
Evaluate loki service usage
labels:
- loki
- graph
- rate
visualization:
type: grafana
grafana:
- expr: 'rate({job="flowlogs-pipeline"}[60s])'
type: lokiGraphPanel
dashboard: details
title:
Loki logs rate
27 changes: 27 additions & 0 deletions pkg/confgen/grafana_jsonnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const panelTargetTypeGraphPanel = "graphPanel"
const singleStatTypeGraphPanel = "singleStat"
const barGaugeTypeGraphPanel = "barGauge"
const heatmapTypeGraphPanel = "heatmap"
const panelTargetTypeLokiGraphPanel = "lokiGraphPanel"

const jsonNetHeaderTemplate = `
local grafana = import 'grafana.libsonnet';
Expand Down Expand Up @@ -137,6 +138,24 @@ const heatmapTemplate = `
}
)`

const lokiGraphPanelTemplate = `
.addPanel(
graphPanel.new(
datasource='loki',
title="{{.Title}}",
)
.addTarget(
prometheus.target(
expr='{{.Expr}}',
)
), gridPos={
x: 0,
y: 0,
w: 25,
h: 20,
}
)`

type Dashboards map[string]Dashboard

type Dashboard struct {
Expand Down Expand Up @@ -206,6 +225,8 @@ func (cg *ConfGen) addPanelsToDashboards(dashboards Dashboards) (Dashboards, err
barGaugeTemplate := template.Must(template.New("graphPanelTemplate").Parse(barGaugeTemplate))
heatmapTemplate := template.Must(template.New("graphPanelTemplate").Parse(heatmapTemplate))

lokiGraphPanelTemplate := template.Must(template.New("graphPanelTemplate").Parse(lokiGraphPanelTemplate))

for _, definition := range cg.visualizations {
if definition.Type != TypeGrafana {
log.Infof("skipping definition of type %s", definition.Type)
Expand Down Expand Up @@ -239,6 +260,12 @@ func (cg *ConfGen) addPanelsToDashboards(dashboards Dashboards) (Dashboards, err
log.Infof("heatmapTemplate.Execute for %s err: %v ", panelTarget.Title, err)
continue
}
case panelTargetTypeLokiGraphPanel:
err := lokiGraphPanelTemplate.Execute(newPanel, panelTarget)
if err != nil {
log.Infof("addPanelAddTargetTemplate.Execute for %s err: %v ", panelTarget.Title, err)
continue
}
default:
log.Infof("unsuported panelTarget.Type %s ", panelTarget.Type)
continue
Expand Down