Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generator HELP override #1106

Merged
merged 1 commit into from
Feb 28, 2024
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
3 changes: 3 additions & 0 deletions generator/FORMAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ modules:
- name: sysUpTime
oid: 1.3.6.1.2.1.1.3
type: gauge
# The HELP text included with the scrape metrics.
help: The value of sysUpTime on the most recent occasion at which any one or
more of this entry's counters suffered a discontinuity - 1.3.6.1.4.1.30065.3.1.1.1.1.46
# See README.md type override for a list of valid types
# Non-numeric types are represented as a gauge with value 1, and the rendered value
# as a label value on that gauge.
Expand Down
1 change: 1 addition & 0 deletions generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ modules:
overrides: # Allows for per-module overrides of bits of MIBs
metricName:
ignore: true # Drops the metric from the output.
help: "string" # Override the generated HELP text provided by the MIB Description.
regex_extracts:
Temp: # A new metric will be created appending this to the metricName to become metricNameTemp.
- regex: '(.*)' # Regex to extract a value from the returned SNMP walks's value.
Expand Down
1 change: 1 addition & 0 deletions generator/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type MetricOverrides struct {
Offset float64 `yaml:"offset,omitempty"`
Scale float64 `yaml:"scale,omitempty"`
Type string `yaml:"type,omitempty"`
Help string `yaml:"help,omitempty"`
}

// UnmarshalYAML implements the yaml.Unmarshaler interface.
Expand Down
1 change: 1 addition & 0 deletions generator/generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ modules:
overrides:
st4TempSensorValue:
scale: 0.1
help: The measured temperature on the sensor in degrees using the scale selected by st4TempSensorScale - 1.3.6.1.4.1.1718.4.1.9.3.1.1

# Palo Alto Firewalls
#
Expand Down
3 changes: 3 additions & 0 deletions generator/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,9 @@ func generateConfigModule(cfg *ModuleConfig, node *Node, nameToNode map[string]*
metric.RegexpExtracts = params.RegexpExtracts
metric.Offset = params.Offset
metric.Scale = params.Scale
if params.Help != "" {
metric.Help = params.Help
}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions generator/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,15 @@ func TestGenerateConfigModule(t *testing.T) {
overrides := make(map[string]MetricOverrides)
overrides["root"] = MetricOverrides{
RegexpExtracts: strMetrics,
Help: "help override",
}

cases := []struct {
node *Node
cfg *ModuleConfig // SNMP generator config.
out *config.Module // SNMP exporter config.
}{
// Simple metric with Regexp override.
// Simple metric with Regexp and Help override.
{
node: &Node{Oid: "1", Access: "ACCESS_READONLY", Type: "INTEGER", Label: "root"},
cfg: &ModuleConfig{
Expand All @@ -203,7 +204,7 @@ func TestGenerateConfigModule(t *testing.T) {
Name: "root",
Oid: "1",
Type: "gauge",
Help: " - 1",
Help: "help override",
RegexpExtracts: strMetrics,
},
},
Expand Down
4 changes: 2 additions & 2 deletions snmp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23309,8 +23309,8 @@ modules:
- name: st4TempSensorValue
oid: 1.3.6.1.4.1.1718.4.1.9.3.1.1
type: gauge
help: The measured temperature on the sensor in tenth degrees using the scale
selected by st4TempSensorScale - 1.3.6.1.4.1.1718.4.1.9.3.1.1
help: The measured temperature on the sensor in degrees using the scale selected
by st4TempSensorScale - 1.3.6.1.4.1.1718.4.1.9.3.1.1
indexes:
- labelname: st4UnitIndex
type: gauge
Expand Down
Loading