Advertisement
G0nz0uk

configv2

Nov 8th, 2024
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.74 KB | None | 0 0
  1. discovery.file "integrations_snmp" {
  2.   files = ["/etc/snmp.json"]
  3. }
  4.  
  5. prometheus.exporter.snmp "integrations_snmp" {
  6.     config_file = "/etc/snmp.yml"
  7.     targets = discovery.file.integrations_snmp.targets
  8. }
  9.  
  10. discovery.relabel "integrations_snmp" {
  11.     targets = prometheus.exporter.snmp.integrations_snmp.targets
  12.  
  13.     rule {
  14.         source_labels = ["job"]
  15.         regex         = "(^.*snmp)\\/(.*)"
  16.         target_label  = "job_snmp"
  17.     }
  18.  
  19.     rule {
  20.         source_labels = ["job"]
  21.         regex         = "(^.*snmp)\\/(.*)"
  22.         target_label  = "snmp_target"
  23.         replacement   = "$2"
  24.     }
  25.  
  26.     rule {
  27.         source_labels = ["instance"]
  28.         target_label  = "instance"
  29.         replacement   = "cisco_snmp_agent"
  30.     }
  31. }
  32.  
  33. prometheus.scrape "integrations_snmp" {
  34.     scrape_timeout = "30s"
  35.     targets        = discovery.relabel.integrations_snmp.output
  36.     forward_to     = [prometheus.remote_write.integrations_snmp.receiver]
  37.     job_name       = "integrations/snmp"
  38.     clustering {
  39.         enabled = true
  40.     }
  41. }
  42.  
  43. prometheus.remote_write "integrations_snmp" {
  44.     endpoint {
  45.         url = "https://192.168.61.61/api/v1/push"
  46.  
  47.         queue_config { }
  48.  
  49.         metadata_config { }
  50.     }
  51. }
  52.  
  53. discovery.relabel "syslog" {
  54.     targets = []
  55.  
  56.     rule {
  57.         source_labels = ["__syslog_message_hostname"]
  58.         target_label  = "host"
  59.     }
  60.  
  61.     rule {
  62.         source_labels = ["__syslog_message_hostname"]
  63.         target_label  = "hostname"
  64.     }
  65.  
  66.     rule {
  67.         source_labels = ["__syslog_message_severity"]
  68.         target_label  = "level"
  69.     }
  70.  
  71.     rule {
  72.         source_labels = ["__syslog_message_app_name"]
  73.         target_label  = "application"
  74.     }
  75.  
  76.     rule {
  77.         source_labels = ["__syslog_message_facility"]
  78.         target_label  = "facility"
  79.     }
  80.  
  81.     rule {
  82.         source_labels = ["__syslog_connection_hostname"]
  83.         target_label  = "connection_hostname"
  84.     }
  85. }
  86.  
  87. loki.source.syslog "syslog" {
  88.     listener {
  89.         address      = "0.0.0.0:601"
  90.         protocol     = "tcp"
  91.         idle_timeout = "0s"
  92.         use_rfc5424_message = true
  93.         labels       = { job = "syslog", component = "loki.source.syslog", protocol = "tcp" }
  94.         max_message_length = 0
  95.     }
  96.     listener {
  97.         address      = "0.0.0.0:51893"
  98.         protocol     = "tcp"
  99.         idle_timeout = "0s"
  100.         use_rfc5424_message = true
  101.         labels       = { job = "syslog", component = "loki.source.syslog", protocol = "tcp" }
  102.         max_message_length = 0
  103.     }
  104.     forward_to    = [loki.write.syslog.receiver]
  105.     relabel_rules = discovery.relabel.syslog.rules
  106. }
  107.  
  108. loki.write "syslog" {
  109.     endpoint {
  110.         url = "http://192.168.61.61:3100/loki/api/v1/push"
  111.     }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement