diff --git a/contrib/dashboards/dashboard_details.json b/contrib/dashboards/dashboard_details.json
index 16e79655a..359482487 100644
--- a/contrib/dashboards/dashboard_details.json
+++ b/contrib/dashboards/dashboard_details.json
@@ -1091,7 +1091,7 @@
"bars": false,
"dashLength": 10,
"dashes": false,
- "datasource": "prometheus",
+ "datasource": "loki",
"fill": 1,
"fillGradient": 0,
"gridPos": {
@@ -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]))",
diff --git a/contrib/dashboards/jsonnet/dashboard_details.jsonnet b/contrib/dashboards/jsonnet/dashboard_details.jsonnet
index 470107bf2..b8e6a8077 100644
--- a/contrib/dashboards/jsonnet/dashboard_details.jsonnet
+++ b/contrib/dashboards/jsonnet/dashboard_details.jsonnet
@@ -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',
diff --git a/docs/confGenerator.md b/docs/confGenerator.md
index e9e17c9d7..4f6446caa 100644
--- a/docs/confGenerator.md
+++ b/docs/confGenerator.md
@@ -150,11 +150,15 @@ For `Histogram`, use `recent_raw_values`.
Prometheus will add labels to the metric based on the (9.6) fields.
(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
diff --git a/docs/metrics.md b/docs/metrics.md
index e255588db..af241cce0 100644
--- a/docs/metrics.md
+++ b/docs/metrics.md
@@ -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) |
|:---|:---|
diff --git a/network_definitions/loki_bandwidth_per_namespace.yaml b/network_definitions/loki_bandwidth_per_namespace.yaml
new file mode 100644
index 000000000..9ae4c9ada
--- /dev/null
+++ b/network_definitions/loki_bandwidth_per_namespace.yaml
@@ -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
diff --git a/network_definitions/loki_logs_per_sec.yaml b/network_definitions/loki_logs_per_sec.yaml
new file mode 100644
index 000000000..a06dba6f6
--- /dev/null
+++ b/network_definitions/loki_logs_per_sec.yaml
@@ -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
diff --git a/pkg/confgen/grafana_jsonnet.go b/pkg/confgen/grafana_jsonnet.go
index 86b6a8ff3..d7d4ef071 100644
--- a/pkg/confgen/grafana_jsonnet.go
+++ b/pkg/confgen/grafana_jsonnet.go
@@ -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';
@@ -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 {
@@ -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)
@@ -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