Skip to content

Commit

Permalink
Merge pull request #183 from BSWANG/main
Browse files Browse the repository at this point in the history
feat: support softirq type in dashboard
  • Loading branch information
BSWANG authored Feb 4, 2024
2 parents 9a17155 + 8ef3e25 commit ac027cf
Show file tree
Hide file tree
Showing 2 changed files with 205 additions and 18 deletions.
195 changes: 191 additions & 4 deletions deploy/resource/kubeskoop-exporter-dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -1826,6 +1826,7 @@
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
Expand Down Expand Up @@ -1898,8 +1899,8 @@
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"expr": "rate(kubeskoop_netsoftirq_schedslow{k8s_node=~\"$node\"}[1m])",
"legendFormat": "{{k8s_node}}",
"expr": "rate(kubeskoop_softirq_schedslow{k8s_node=~\"$node\"}[1m]) ",
"legendFormat": "{{softirq_type}}",
"range": true,
"refId": "A"
}
Expand Down Expand Up @@ -1990,15 +1991,201 @@
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"expr": "rate(kubeskoop_netsoftirq_schedslow100ms{k8s_node=~\"$node\"}[1m])",
"legendFormat": "{{k8s_node}}",
"expr": "rate(kubeskoop_softirq_schedslow100ms{k8s_node=~\"$node\"}[1m])",
"legendFormat": "{{softirq_type}}",
"range": true,
"refId": "A"
}
],
"title": "Network softirq Sched more than 100ms",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
},
{
"color": "red",
"value": 80
}
]
},
"unit": "cps"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 83
},
"id": 86,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"expr": "rate(kubeskoop_softirq_excuteslow{k8s_node=~\"$node\"}[1m]) ",
"legendFormat": "{{softirq_type}}",
"range": true,
"refId": "A"
}
],
"title": "Net Softirq execute slow(more than 10ms)",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
},
"unit": "cps"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 83
},
"id": 87,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"expr": "rate(kubeskoop_softirq_excuteslow100ms{k8s_node=~\"$node\"}[1m]) ",
"legendFormat": "{{softirq_type}}",
"range": true,
"refId": "A"
}
],
"title": "Net Softirq execute slow(more than 100ms)",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
Expand Down
28 changes: 14 additions & 14 deletions pkg/exporter/probe/tracesoftirq/tracesoftirq.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ const (
)

var (
probeName = "softirq"
softirqTypes = []string{"hi", "timer", "net_tx", "net_rx", "block", "irq_poll", "tasklet", "sched", "hrtimer", "rcu"}
_netSoftirqProbe = &softirqProbe{
probeName = "softirq"
softirqTypes = []string{"hi", "timer", "net_tx", "net_rx", "block", "irq_poll", "tasklet", "sched", "hrtimer", "rcu"}
_softirqProbe = &softirqProbe{
metricsMap: map[string]map[string]uint64{
SOFTIRQ_SCHED_SLOW: {},
SOFTIRQ_SCHED_100MS: {},
Expand All @@ -60,7 +60,7 @@ func metricsProbeCreator(args softirqArgs) (probe.MetricsProbe, error) {
if len(args.SoftirqTypes) == 0 {
args.SoftirqTypes = []string{"net_rx"}
}
_netSoftirqProbe.metricsProbeIrqTypes = softirqTypesBits(args.SoftirqTypes)
_softirqProbe.metricsProbeIrqTypes = softirqTypesBits(args.SoftirqTypes)

p := &metricsProbe{}
opts := probe.BatchMetricsOpts{
Expand All @@ -82,7 +82,7 @@ func eventProbeCreator(sink chan<- *probe.Event, args softirqArgs) (probe.EventP
if len(args.SoftirqTypes) == 0 {
args.SoftirqTypes = []string{"net_rx"}
}
_netSoftirqProbe.eventProbeIrqTypes = softirqTypesBits(args.SoftirqTypes)
_softirqProbe.eventProbeIrqTypes = softirqTypesBits(args.SoftirqTypes)
p := &eventProbe{
sink: sink,
}
Expand All @@ -93,19 +93,19 @@ type metricsProbe struct {
}

func (p *metricsProbe) Start(_ context.Context) error {
return _netSoftirqProbe.start(probe.ProbeTypeMetrics)
return _softirqProbe.start(probe.ProbeTypeMetrics)
}

func (p *metricsProbe) Stop(_ context.Context) error {
return _netSoftirqProbe.stop(probe.ProbeTypeMetrics)
return _softirqProbe.stop(probe.ProbeTypeMetrics)
}

func (p *metricsProbe) collectOnce(emit probe.Emit) error {
_netSoftirqProbe.metricsLock.RLock()
defer _netSoftirqProbe.metricsLock.RUnlock()
_softirqProbe.metricsLock.RLock()
defer _softirqProbe.metricsLock.RUnlock()
nodeName := nettop.GetNodeName()
for metricsName, values := range _netSoftirqProbe.metricsMap {
for _, irqType := range enabledIrqTypes(_netSoftirqProbe.metricsProbeIrqTypes) {
for metricsName, values := range _softirqProbe.metricsMap {
for _, irqType := range enabledIrqTypes(_softirqProbe.metricsProbeIrqTypes) {
emit(metricsName, []string{nodeName, irqType}, float64(values[irqType]))
}
}
Expand All @@ -117,17 +117,17 @@ type eventProbe struct {
}

func (e *eventProbe) Start(_ context.Context) error {
err := _netSoftirqProbe.start(probe.ProbeTypeEvent)
err := _softirqProbe.start(probe.ProbeTypeEvent)
if err != nil {
return err
}

_netSoftirqProbe.sink = e.sink
_softirqProbe.sink = e.sink
return nil
}

func (e *eventProbe) Stop(_ context.Context) error {
return _netSoftirqProbe.stop(probe.ProbeTypeEvent)
return _softirqProbe.stop(probe.ProbeTypeEvent)
}

type softirqProbe struct {
Expand Down

0 comments on commit ac027cf

Please sign in to comment.