claranet / terraform-signalfx-detectors

Collection of terraform modules for SignalFx detectors.
Mozilla Public License 2.0
22 stars 31 forks source link

jmx geometry metaspace #216

Open pierreislande opened 3 years ago

pierreislande commented 3 years ago

Hello, could you please add this, to the jmx module if possible: https://github.com/claranet/terraform-signalfx-detectors/tree/master/modules/smart-agent_genericjmx

resource "signalfx_detector" "jmx_memory_geometry_metaspace_space_usage" {
  name = "${join("", formatlist("[%s]", var.prefixes))}[${var.environment}] JMX Memory Geometry Metaspace Space Usage"

  program_text = <<-EOF
    A = data('jmx_memory.used', filter=filter('plugin_instance', 'memory_pool-Metaspace') and ${module.filter-tags.filter_custom})${var.jmx_memory_geometry_metaspace_space_used_aggregation_function}${var.jmx_memory_geometry_metaspace_space_used_transformation_function}
    B = data('jmx_memory.max', filter=filter('plugin_instance', 'memory_pool-Metaspace') and ${module.filter-tags.filter_custom})${var.jmx_memory_geometry_metaspace_space_max_aggregation_function}${var.jmx_memory_geometry_metaspace_space_max_transformation_function}
    signal = ((A/B).fill(0).scale(100)).publish('signal')
    detect(when(signal > ${var.jmx_memory_geometry_metaspace_space_usage_threshold_critical})).publish('critical')
    detect(when(signal > ${var.jmx_memory_geometry_metaspace_space_usage_threshold_warning}) and (signal < ${var.jmx_memory_geometry_metaspace_space_usage_threshold_critical})).publish('WARN')
EOF

  rule {
    description           = "is too low > ${var.jmx_memory_geometry_metaspace_space_usage_threshold_warning}"
    severity              = "Warning"
    detect_label          = "WARN"
    disabled              = coalesce(var.jmx_memory_geometry_metaspace_space_usage_disabled_warning, var.detectors_disabled)
    notifications         = coalescelist(var.jmx_memory_geometry_metaspace_space_usage_notifications_warning, var.notifications)
    parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} on {{{dimensions}}}"
  }
  rule {
    description           = "is too low > ${var.jmx_memory_geometry_metaspace_space_usage_threshold_critical}"
    severity              = "Critical"
    detect_label          = "critical"
    disabled              = coalesce(var.jmx_memory_geometry_metaspace_space_usage_disabled_critical, var.detectors_disabled)
    notifications         = coalescelist(var.jmx_memory_geometry_metaspace_space_usage_notifications_critical, var.notifications)
    parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} on {{{dimensions}}}"
  }
}
xp-1000 commented 3 years ago

please provide a real use case because it seems too much specific to be relevant in this repo.