mirror of
https://github.com/unpoller/unpoller.git
synced 2026-04-05 08:54:09 -04:00
* feat(promunifi): add firewall policy metrics (closes #928) Bump unifi client to v5.22.0 and wire up firewall policy data end-to-end: - poller.Metrics: add FirewallPolicies []any slice - inputunifi: collect GetFirewallPolicies() per poll cycle; apply DefaultSiteNameOverride; augment into poller.Metrics - promunifi: export per-rule (rule_enabled, rule_index) and per-site aggregate metrics (rules_total, rules_enabled, rules_disabled, rules_by_action, rules_predefined, rules_custom, rules_logging_enabled) Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * feat: export firewall policies to influx, datadog, and otel outputs Extends firewall policy support (PR #979) to all remaining output plugins: - influxunifi: batchFirewallPolicy() writes measurement "firewall_policy" with tags (rule_name, action, protocol, ip_version, source/dest zone, site_name, source) and fields (enabled, index, predefined, logging) - datadogunifi: batchFirewallPolicy() emits the same data as Datadog gauges under the "firewall_policy.*" namespace - otelunifi: exportFirewallPolicies() emits per-rule gauges (unifi_firewall_rule_enabled, unifi_firewall_rule_index) and per-site aggregates (rules_total, rules_enabled, rules_disabled, rules_by_action, rules_predefined, rules_custom, rules_logging_enabled) Also rebases onto master to pick up the otelunifi plugin (PR #978). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
48 lines
899 B
Go
48 lines
899 B
Go
package influxunifi
|
|
|
|
import (
|
|
"github.com/unpoller/unifi/v5"
|
|
)
|
|
|
|
// batchFirewallPolicy generates a firewall policy datapoint for InfluxDB.
|
|
func (u *InfluxUnifi) batchFirewallPolicy(r report, p *unifi.FirewallPolicy) {
|
|
if p == nil {
|
|
return
|
|
}
|
|
|
|
tags := map[string]string{
|
|
"rule_name": p.Name,
|
|
"action": p.Action,
|
|
"protocol": p.Protocol,
|
|
"ip_version": p.IPVersion,
|
|
"source_zone": p.Source.ZoneID,
|
|
"dest_zone": p.Destination.ZoneID,
|
|
"site_name": p.SiteName,
|
|
"source": p.SourceName,
|
|
}
|
|
|
|
enabled := 0
|
|
if p.Enabled.Val {
|
|
enabled = 1
|
|
}
|
|
|
|
predefined := 0
|
|
if p.Predefined.Val {
|
|
predefined = 1
|
|
}
|
|
|
|
logging := 0
|
|
if p.Logging.Val {
|
|
logging = 1
|
|
}
|
|
|
|
fields := map[string]any{
|
|
"enabled": enabled,
|
|
"index": p.Index.Val,
|
|
"predefined": predefined,
|
|
"logging": logging,
|
|
}
|
|
|
|
r.send(&metric{Table: "firewall_policy", Tags: tags, Fields: fields})
|
|
}
|