Saltstack Official Linux Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
5.6KB

  1. {%- if pillar.get('fluentd', {}).get('agent', {}).get('enabled', False) %}
  2. {%- set positiondb = pillar.fluentd.agent.dir.positiondb %}
  3. {%- if grains.get('init') == 'systemd' %}
  4. agent:
  5. plugin:
  6. fluent-plugin-systemd:
  7. deb: ['td-agent-additional-plugins']
  8. config:
  9. label:
  10. default_metric:
  11. filter:
  12. metric_failed_user:
  13. tag: metric.failed_user
  14. type: prometheus
  15. metric:
  16. - name: failed_logins_total
  17. type: counter
  18. desc: The total number of failed logins.
  19. label:
  20. - name: host
  21. value: ${Hostname}
  22. metric_out_of_memory:
  23. tag: metric.out_of_memory
  24. type: prometheus
  25. metric:
  26. - name: out_of_memory_total
  27. type: counter
  28. desc: The total number of OOM.
  29. label:
  30. - name: host
  31. value: ${Hostname}
  32. metric_hdd_errors_parse:
  33. tag: metric.hdd_errors
  34. type: parser
  35. key_name: Payload
  36. parser:
  37. type: regexp
  38. format: '/(?<device>[sv]d[a-z]+\d*)/'
  39. metric_hdd_errors:
  40. tag: metric.hdd_errors
  41. require:
  42. - metric_hdd_errors_parse
  43. type: prometheus
  44. metric:
  45. - name: hdd_errors_total
  46. type: counter
  47. desc: The total number of hdd errors.
  48. label:
  49. - name: host
  50. value: ${Hostname}
  51. - name: device
  52. value: ${device}
  53. systemd:
  54. input:
  55. systemd:
  56. type: systemd
  57. tag: systemd.source
  58. path: /run/log/journal
  59. pos_file: {{ positiondb }}/systemd.source.pos
  60. entry:
  61. field_map:
  62. MESSAGE: 'Payload'
  63. _CMDLINE: 'process'
  64. _PID: 'Pid'
  65. _COMM: 'programname'
  66. _SYSTEMD_UNIT: 'service'
  67. syslog_identifier: 'ident'
  68. priority: 'Severity'
  69. field_map_strict: True
  70. fields_strip_underscores: True
  71. fields_lowercase: True
  72. filter:
  73. add_severity_label:
  74. tag: systemd.source
  75. type: record_transformer
  76. enable_ruby: true
  77. record:
  78. - name: severity_label
  79. value: '${ {"TRACE"=>8,"DEBUG"=>7,"INFO"=>6,"NOTICE"=>5,"WARNING"=>4,"ERROR"=>3,"CRITICAL"=>2,"ALERT"=>1,"EMERGENCY"=>0}.key(record["Severity"].to_i) }'
  80. - name: source
  81. value: systemd
  82. match:
  83. rewrite_tag:
  84. tag: systemd.source
  85. type: rewrite_tag_filter
  86. rule:
  87. - name: ident
  88. regexp: '^(.*)$'
  89. result: $1.systemd
  90. push_to_default:
  91. tag: '*.systemd'
  92. type: copy
  93. store:
  94. - type: relabel
  95. label: default_output
  96. - type: rewrite_tag_filter
  97. rule:
  98. - name: Payload
  99. regexp: '^Invalid user'
  100. result: metric.failed_user
  101. - name: Payload
  102. regexp: '^Out of memory'
  103. result: metric.out_of_memory
  104. - name: Payload
  105. regexp: >-
  106. 'error.*\b[sv]d[a-z]{1,2}\d{0,3}\b.*'
  107. result: metric.hdd_errors
  108. - name: Payload
  109. regexp: >-
  110. '\b[sv]d[a-z]{1,2}\d{0,3}\b.*error'
  111. result: metric.hdd_errors
  112. push_to_metric:
  113. tag: 'metric.**'
  114. type: relabel
  115. label: default_metric
  116. {%- else %}
  117. agent:
  118. config:
  119. label:
  120. default_metric:
  121. filter:
  122. metric_hdd_errors_parse:
  123. tag: metric.hdd_errors
  124. type: parser
  125. key_name: Payload
  126. parser:
  127. type: regexp
  128. format: '/(?<device>[sv]d[a-z]+\d*)/'
  129. metric_hdd_errors:
  130. tag: metric.hdd_errors
  131. require:
  132. - metric_hdd_errors_parse
  133. type: prometheus
  134. metric:
  135. - name: hdd_errors_total
  136. type: counter
  137. desc: The total number of hdd errors.
  138. label:
  139. - name: host
  140. value: ${Hostname}
  141. - name: device
  142. value: ${device}
  143. syslog:
  144. input:
  145. syslog_file:
  146. type: tail
  147. tag: linux.syslog
  148. path: /var/log/syslog
  149. pos_file: {{ positiondb }}/linux_syslog.pos
  150. suppress_parse_error_log: true
  151. parser:
  152. type: regexp
  153. format: >-
  154. '/(?<Payload>.*(?<device>[sv]d[a-z]{1,2}\d{0,3}).*)/'
  155. match:
  156. push_to_default:
  157. tag: 'linux.**'
  158. type: copy
  159. store:
  160. - type: relabel
  161. label: default_output
  162. - type: rewrite_tag_filter
  163. rule:
  164. - name: Payload
  165. regexp: >-
  166. 'error.*\b[sv]d[a-z]{1,2}\d{0,3}\b.*'
  167. result: metric.hdd_errors
  168. - name: Payload
  169. regexp: >-
  170. '\b[sv]d[a-z]{1,2}\d{0,3}\b.*error'
  171. result: metric.hdd_errors
  172. push_to_metric:
  173. tag: 'metric.**'
  174. type: relabel
  175. label: default_metric
  176. {%- endif %}
  177. {%- endif %}