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.

176 lines
5.5KB

  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. match:
  81. rewrite_tag:
  82. tag: systemd.source
  83. type: rewrite_tag_filter
  84. rule:
  85. - name: ident
  86. regexp: '^(.*)$'
  87. result: __TAG__.$1
  88. push_to_default:
  89. tag: 'systemd.source.*'
  90. type: copy
  91. store:
  92. - type: relabel
  93. label: default_output
  94. - type: rewrite_tag_filter
  95. rule:
  96. - name: Payload
  97. regexp: '^Invalid user'
  98. result: metric.failed_user
  99. - name: Payload
  100. regexp: '^Out of memory'
  101. result: metric.out_of_memory
  102. - name: Payload
  103. regexp: >-
  104. 'error.*\b[sv]d[a-z]{1,2}\d{0,3}\b.*'
  105. result: metric.hdd_errors
  106. - name: Payload
  107. regexp: >-
  108. '\b[sv]d[a-z]{1,2}\d{0,3}\b.*error'
  109. result: metric.hdd_errors
  110. push_to_metric:
  111. tag: 'metric.**'
  112. type: relabel
  113. label: default_metric
  114. {%- else %}
  115. agent:
  116. config:
  117. label:
  118. default_metric:
  119. filter:
  120. metric_hdd_errors_parse:
  121. tag: metric.hdd_errors
  122. type: parser
  123. key_name: Payload
  124. parser:
  125. type: regexp
  126. format: '/(?<device>[sv]d[a-z]+\d*)/'
  127. metric_hdd_errors:
  128. tag: metric.hdd_errors
  129. require:
  130. - metric_hdd_errors_parse
  131. type: prometheus
  132. metric:
  133. - name: hdd_errors_total
  134. type: counter
  135. desc: The total number of hdd errors.
  136. label:
  137. - name: host
  138. value: ${Hostname}
  139. - name: device
  140. value: ${device}
  141. syslog:
  142. input:
  143. syslog_file:
  144. type: tail
  145. tag: linux.syslog
  146. path: /var/log/syslog
  147. pos_file: {{ positiondb }}/linux_syslog.pos
  148. suppress_parse_error_log: true
  149. parser:
  150. type: regexp
  151. format: >-
  152. '/(?<Payload>.*(?<device>[sv]d[a-z]{1,2}\d{0,3}).*)/'
  153. match:
  154. push_to_default:
  155. tag: 'linux.**'
  156. type: copy
  157. store:
  158. - type: relabel
  159. label: default_output
  160. - type: rewrite_tag_filter
  161. rule:
  162. - name: Payload
  163. regexp: >-
  164. 'error.*\b[sv]d[a-z]{1,2}\d{0,3}\b.*'
  165. result: metric.hdd_errors
  166. - name: Payload
  167. regexp: >-
  168. '\b[sv]d[a-z]{1,2}\d{0,3}\b.*error'
  169. result: metric.hdd_errors
  170. push_to_metric:
  171. tag: 'metric.**'
  172. type: relabel
  173. label: default_metric
  174. {%- endif %}
  175. {%- endif %}