def _vs_elements(cls): return [ ("title", TextUnicode(default_value="", title=_("Figure title"))), ("metric", MetricName()), # MetricChoice would be nicer, but is CEE ("rrd_consolidation", DropdownChoice( choices=[ ("average", _("Average")), ("min", _("Minimum")), ("max", _("Maximum")), ], default_value="average", title="RRD consolidation", help= _("Consolidation function for the [cms_graphing#rrds|RRD] data column" ), )), ( "time_range", CascadingDropdown( title=_("Timerange"), orientation="horizontal", choices=[ ("current", _("Only show current value")), ( "range", _("Show historic values"), # TODO: add RRD consolidation, here and in _get_data below Timerange(title=_("Time range to consider"), default_value="d0", allow_empty=True)), ], default_value="current")) ]
def _vs_elements() -> DictionaryElements: return [ ("metric", MetricName()), ("time_range", Timerange( title=_("Time range"), default_value='d0', )), ( "metric_color", ColorWithThemeOrMetricDefault( title=_("Color of the scattered dots"), default_value="default", ), ), ( "avg_color", ColorWithThemeOrMetricDefault( title=_("Color of the average"), default_value="default", ), ), ( "median_color", ColorWithThemeOrMetricDefault( title=_("Color of the median"), default_value="default", ), ), ]
def _vs_elements(cls): return [ ("metric", MetricName() ), # MetricChoice would be nicer, but we use the context filters ("time_range", CascadingDropdown( title=_("Timerange"), orientation="horizontal", choices=[ ("current", _("Only show current value")), ("range", _("Show historic values"), Dictionary( optional_keys=False, elements=[ ('window', Timerange(title=_("Time range to consider"), default_value="d0", allow_empty=True)), ("rrd_consolidation", DropdownChoice( choices=[ ("average", _("Average")), ("min", _("Minimum")), ("max", _("Maximum")), ], default_value="max", title="RRD consolidation", help= _("Consolidation function for the [cms_graphing#rrds|RRD] data column" ), )), ])), ], default_value="current")) ]
def vs_parameters(cls): return Dictionary(title=_("Properties"), render="form", optional_keys=[], elements=[ ("metric", MetricName()), ("time_range", Timerange( title=_("Time range"), default_value='d0', )), ])
def _vs_elements() -> DictionaryElements: return [ ("metric", MetricName()), ("time_range", Timerange( title=_("Time range"), default_value='d0', )), ("metric_color", GraphColor(title=_("Color for the main metric scattered dots"), default_value="default")), ("avg_color", GraphColor(title=_("Color for the average line"), default_value="default")), ("median_color", GraphColor(title=_("Color for the median line"), default_value="default")), ]
def vs_parameters(cls): return Dictionary( title=_("Properties"), render="form", optional_keys=[], elements=[ ("metric", MetricName()), ("time_range", Timerange( title=_("Time range"), default_value='d0', )), ("metric_color", GraphColor( title=_("Color for the main metric scattered dots"), default_value="default")), ("avg_color", GraphColor(title=_("Color for the average line"), default_value="default")), ("median_color", GraphColor(title=_("Color for the median line"), default_value="default")), ])
def vs_parameters(cls): return Dictionary(title=_("Properties"), render="form", optional_keys=[], elements=cls._scatterplot_vs_components() + [("metric", MetricName())])
def _vs_elements(cls): return [ ("metric", MetricName() ), # MetricChoice would be nicer, but we use the context filters ("time_range", CascadingDropdown( title=_("Timerange"), orientation="horizontal", choices=[ ("current", _("Only show current value")), ("range", _("Show historic values"), Dictionary( optional_keys=False, elements=[ ('window', Timerange(title=_("Time range to consider"), default_value="d0", allow_empty=True)), ("rrd_consolidation", DropdownChoice( choices=[ ("average", _("Average")), ("min", _("Minimum")), ("max", _("Maximum")), ], default_value="max", title="RRD consolidation", help= _("Consolidation function for the [cms_graphing#rrds|RRD] data column" ), )), ])), ], default_value="current")), ("display_range", CascadingDropdown( title=_("Display range"), choices=[ ("infer", _("Infer range from available data and check output")), ("fixed", _("Fixed range"), Tuple( title=_("Fixed range"), help=_( "Use a fixed range for the Data displayed. This " "value has no scaling. If your metric is in the " "range of MB, you'll need to place 9 zeros for " "display to make sense."), elements=[ Float(title=_("Minimum")), Float(title=_("Maximum")), ])), ])), ("status_border", DropdownChoice( title=_("Status border"), choices=[ (False, _("Do not show any service status border")), ("not_ok", _("Draw a status border when service is not OK")), ("always", _("Always draw the service status on the border")), ], default_value="not_ok")), ]
def _vs_elements(with_elements) -> DictionaryElements: yield ("metric", MetricName() ) # MetricChoice would be nicer, but we use the context filters if "time_range" in with_elements: yield "time_range", CascadingDropdown( title=_("Timerange"), orientation="horizontal", choices=[ ( "current", _("Only show current value"), ), ( "range", _("Show historic values"), Dictionary( optional_keys=False, elements=_time_range_historic_dict_elements( with_elements), ), ), ], default_value="current", ) if "display_range" in with_elements: def validate_range(value, varprefix): _min, _max = value if _min >= _max: raise MKUserError( varprefix, _("Display range: Minimum must be strictly less than maximum" )) fix_range: CascadingDropdownChoice = ( "fixed", _("Fixed range"), ValuesWithUnits(vs_name="display_range", metric_vs_name="metric", help=_( "Set the range in which data is displayed. " "Having selected a metric before auto selects " "here the matching unit of the metric."), elements=[_("Minimum"), _("Maximum")], validate_value_elemets=validate_range)) auto_range: CascadingDropdownChoice = ( "automatic", _("Automatically adjusted to available data")) choices = [fix_range] + ([auto_range] if "automatic_range" in with_elements else []) yield "display_range", CascadingDropdown( title=_("Data range"), choices=choices, default_value="automatic" if "automatic_range" in with_elements else "fixed") if "toggle_range_display" in with_elements: yield "toggle_range_display", DropdownChoice( title=_("Show range limits"), choices=[(True, _("Show the limits of values displayed")), (False, _("Don't show information of limits"))]) if "inner_state_display" in with_elements: yield "inner_state_display", DropdownChoice( title=_("Metric color"), choices=[ (None, _("Follow theme default")), ("service", _("Color value after SERVICE state")), ("metric", _("Color value following it's METRIC THRESHOLDS if available") ) ], ) if "status_border" in with_elements: yield "status_border", DropdownChoice( title=_("Status border"), choices=[ (None, _("Do not show any status border")), ("service", _("Draw a status border when SERVICE is not OK")), ("metric", _("Draw a status border when METRICS THRESHOLDS are crossed") ), ], default_value="service")
def _valuespec_generic_metrics_prometheus(): namespace_element = ( "prepend_namespaces", DropdownChoice( title=_("Prepend namespace prefix for hosts"), help=_( "If a cluster uses multiple namespaces you need to activate this option. " "Hosts for namespaced Kubernetes objects will then be prefixed with the " "name of their namespace. This makes Kubernetes resources in different " "namespaces that have the same name distinguishable, but results in " "longer hostnames." ), choices=[ ("use_namespace", _("Use a namespace prefix")), ("omit_namespace", _("Don't use a namespace prefix")), ], ), ) return Transform( valuespec=Dictionary( elements=[ ( "connection", CascadingDropdown( choices=[ ( "ip_address", _("IP Address"), Dictionary( elements=api_request_connection_elements( help_text=_( "Specifies a URL path prefix, which is prepended to API calls " "to the Prometheus API. If this option is not relevant for " "your installation, please leave it unchecked." ), default_port=6443, ), ), ), ( "host_name", _("Host name"), Dictionary( elements=api_request_connection_elements( help_text=_( "Specifies a URL path prefix, which is prepended to API calls " "to the Prometheus API. If this option is not relevant for " "your installation, please leave it unchecked." ), default_port=6443, ), ), ), ( "url_custom", _("Custom URL"), Dictionary( elements=[ ( "url_address", TextInput( title=_("Custom URL server address"), help=_( "Specify a custom URL to connect to " "your server. Do not include the " "protocol. This option overwrites " "all available options such as port and " "other URL prefixes." ), allow_empty=False, ), ) ], optional_keys=[], ), ), ], title=_("Prometheus connection option"), ), ), ssl_verification(), api_request_authentication(), ( "protocol", DropdownChoice( title=_("Protocol"), choices=[ ("http", "HTTP"), ("https", "HTTPS"), ], ), ), ( "exporter", ListOf( valuespec=CascadingDropdown( choices=[ ( "node_exporter", _("Node Exporter"), Dictionary( elements=[ ( "host_mapping", Hostname( title=_("Explicitly map Node Exporter host"), allow_empty=True, help=_( "Per default, Checkmk tries to map the underlying Checkmk host " "to the Node Exporter host which contains either the Checkmk " 'hostname, host address or "localhost" in its endpoint address. ' "The created services of the mapped Node Exporter will " "be assigned to the Checkmk host. A piggyback host for each " "Node Exporter host will be created if none of the options are " "valid. " "This option allows you to explicitly map one of your Node " "Exporter hosts to the underlying Checkmk host. This can be " "used if the default options do not apply to your setup." ), ), ), ( "entities", ListChoice( choices=[ ("df", _("Filesystems")), ("diskstat", _("Disk IO")), ("mem", _("Memory")), ( "kernel", _( "CPU utilization & Kernel performance" ), ), ], default_value=[ "df", "diskstat", "mem", "kernel", ], allow_empty=False, title=_("Retrieve information about..."), help=_( "For your respective kernel select the hardware or OS entity " "you would like to retrieve information about." ), ), ), ], title=_("Node Exporter metrics"), optional_keys=["host_mapping"], ), ), ( "kube_state", _("Kube-state-metrics"), Dictionary( elements=[ ( "cluster_name", Hostname( title=_("Cluster name"), allow_empty=False, help=_( "You must specify a name for your Kubernetes cluster. The provided name" " will be used to create a piggyback host for the cluster related services." ), ), ), namespace_element, filter_kubernetes_namespace_element(), ( "entities", ListChoice( choices=[ ("cluster", _("Cluster")), ("nodes", _("Nodes")), ("services", _("Services")), ("pods", _("Pods")), ("daemon_sets", _("Daemon sets")), ], default_value=[ "cluster", "nodes", "services", "pods", "daemon_sets", ], allow_empty=False, title=_("Retrieve information about..."), help=_( "For your Kubernetes cluster select for which entity levels " "you would like to retrieve information about. Piggyback hosts " "for the respective entities will be created." ), ), ), ], title=_("Kube state metrics"), optional_keys=["namespace_include_patterns"], ), ), ( "cadvisor", _("cAdvisor"), Dictionary( elements=[ ( "entity_level", CascadingDropdown( title=_( "Entity level used to create Checkmk piggyback hosts" ), help=_( "The retrieved information from the cAdvisor will be aggregated according" " to the selected entity level. Resulting services will be allocated to the created" " Checkmk piggyback hosts." ), choices=[ ( "container", _( "Container - Display the information on container level" ), Dictionary( elements=[ ( "container_id", DropdownChoice( title=_( "Host name used for containers" ), help=_( "For Containers - Choose which identifier is used for the monitored containers." " This will affect the name used for the piggyback host" " corresponding to the container, as well as items for" " services created on the node for each container." ), choices=[ ( "short", _( "Short - Use the first 12 characters of the docker container ID" ), ), ( "long", _( "Long - Use the full docker container ID" ), ), ( "name", _( "Name - Use the name of the container" ), ), ], ), ) ], optional_keys=[], ), ), ( "pod", _( "Pod - Display the information for pod level" ), Dictionary( elements=[namespace_element], optional_keys=[], ), ), ( "both", _( "Both - Display the information for both, pod and container, levels" ), Dictionary( elements=[ ( "container_id", DropdownChoice( title=_( "Host name used for containers" ), help=_( "For Containers - Choose which identifier is used for the monitored containers." " This will affect the name used for the piggyback host" " corresponding to the container, as well as items for" " services created on the node for each container." ), choices=[ ( "short", _( "Short - Use the first 12 characters of the docker container ID" ), ), ( "long", _( "Long - Use the full docker container ID" ), ), ( "name", _( "Name - Use the name of the container" ), ), ], ), ), namespace_element, ], optional_keys=[], ), ), ], ), ), filter_kubernetes_namespace_element(), ( "entities", ListChoice( choices=[ ("diskio", _("Disk IO")), ("cpu", _("CPU utilization")), ("df", _("Filesystem")), ("if", _("Network")), ("memory", _("Memory")), ], default_value=[ "diskio", "cpu", "df", "if", "memory", ], allow_empty=False, title=_("Retrieve information about..."), help=_( "For your respective kernel select the hardware or OS entity " "you would like to retrieve information about." ), ), ), ], title=_("CAdvisor"), validate=_check_not_empty_exporter_dict, optional_keys=[ "diskio", "cpu", "df", "if", "memory", "namespace_include_patterns", ], ), ), ] ), add_label=_("Add new Scrape Target"), title=_( "Prometheus Scrape Targets (include Prometheus Exporters) to fetch information from" ), help=_( "You can specify which Scrape Targets including Exporters " "are connected to your Prometheus instance. The Prometheus " "Special Agent will automatically generate services for the " "selected monitoring information. You can create your own " "defined services with the custom PromQL query option below " "if one of the Scrape Target types are not listed here." ), ), ), ( "promql_checks", ListOf( valuespec=Dictionary( elements=[ ( "service_description", TextInput( title=_("Service name"), allow_empty=False, ), ), ( "host_name", Hostname( title=_("Assign service to following host"), allow_empty=False, help=_( "Specify the host to which the resulting " "service will be assigned to. The host " "should be configured to allow Piggyback " "data." ), ), ), ( "metric_components", ListOf( valuespec=Dictionary( title=_("PromQL query"), elements=[ ( "metric_label", TextInput( title=_("Metric label"), allow_empty=False, help=_( "The metric label is displayed alongside the " "queried value in the status detail the resulting service. " "The metric name will be taken as label if " "nothing was specified." ), ), ), ("metric_name", MetricName()), ( "promql_query", TextInput( title=_( "PromQL query (only single return value permitted)" ), allow_empty=False, size=80, help=_( 'Example PromQL query: up{job="node_exporter"}' ), ), ), ( "levels", Dictionary( elements=[ ( "lower_levels", Tuple( title=_("Lower levels"), elements=[ Float( title=_("Warning below") ), Float( title=_( "Critical below" ) ), ], ), ), ( "upper_levels", Tuple( title=_("Upper levels"), elements=[ Float( title=_("Warning at") ), Float( title=_("Critical at") ), ], ), ), ], title="Metric levels", validate=_verify_prometheus_empty, help=_( "Specify upper and/or lower levels for the queried PromQL value. This option " "should be used for simple cases where levels are only required once. You " "should use the Prometheus custom services monitoring rule if you want to " "specify a rule which applies to multiple Prometheus custom services at once. " "The custom rule always has priority over the rule specified here " "if the two overlap." ), ), ), ], optional_keys=["metric_name", "levels"], ), title=_("PromQL queries for Service"), add_label=_("Add new PromQL query"), allow_empty=False, magic="@;@", validate=_validate_prometheus_service_metrics, ), ), ], optional_keys=["host_name"], ), title=_("Service creation using PromQL queries"), add_label=_("Add new Service"), ), ), ], title=_("Prometheus"), optional_keys=["auth_basic"], ), forth=_transform_agent_prometheus, )
def _vs_elements(cls): return [ ("metric", MetricName() ), # MetricChoice would be nicer, but we use the context filters ("time_range", CascadingDropdown( title=_("Timerange"), orientation="horizontal", choices=[ ("current", _("Only show current value")), ("range", _("Show historic values"), Dictionary( optional_keys=False, elements=[ ('window', Timerange(title=_("Time range to consider"), default_value="d0", allow_empty=True)), ("rrd_consolidation", DropdownChoice( choices=[ ("average", _("Average")), ("min", _("Minimum")), ("max", _("Maximum")), ], default_value="max", title="RRD consolidation", help= _("Consolidation function for the [cms_graphing#rrds|RRD] data column" ), )), ])), ], default_value="current")), ("display_range", CascadingDropdown( title=_("Display range"), choices=[ ("infer", _("Automatic")), ("fixed", _("Fixed range"), ValuesWithUnits( vs_name="display_range", metric_vs_name="metric", help=_( "Set the range in which data is displayed. " "Having selected a metric before auto selects " "here the matching unit of the metric."), elements=[_("Minimum"), _("Maximum")])), ])), ("status_border", DropdownChoice( title=_("Status border"), choices=[ (False, _("Do not show any service status border")), ("not_ok", _("Draw a status border when service is not OK")), ("always", _("Always draw the service status on the border")), ], default_value="not_ok")), ]
def _vs_elements(with_elements) -> DictionaryElements: yield ("metric", MetricName() ) # MetricChoice would be nicer, but we use the context filters if "time_range" in with_elements: yield "time_range", CascadingDropdown( title=_("Timerange"), orientation="horizontal", choices=[ ( "current", _("Only show current value"), ), ( "range", _("Show historic values"), Dictionary( optional_keys=False, elements=_time_range_historic_dict_elements( with_elements), ), ), ], default_value="current", ) if "display_range" in with_elements: def validate_range(value, varprefix): _min, _max = value if _min >= _max: raise MKUserError( varprefix, _("Display range: Minimum must be strictly less than maximum" )) yield "display_range", CascadingDropdown( title=_("Display range"), choices=[ ("fixed", _("Fixed range"), ValuesWithUnits( vs_name="display_range", metric_vs_name="metric", help=_("Set the range in which data is displayed. " "Having selected a metric before auto selects " "here the matching unit of the metric."), elements=[_("Minimum"), _("Maximum")], validate_value_elemets=validate_range)), # ("infer", _("Automatic")), # For future logic ], default_value="fixed") if "metric_status_display" in with_elements: yield "metric_status_display", DropdownChoice( title=_("Metric Status"), choices=[(None, _("Metric value is displayed in neutral color")), ("text", _("Metric state is colored in its value")), ("background", _("Metric status is colored on the dashlet background")) ], ) if "status_border" in with_elements: yield "status_border", DropdownChoice( title=_("Status border"), choices=[ (False, _("Do not show any service status border")), ("not_ok", _("Draw a status border when service is not OK")), ("always", _("Always draw the service status on the border")), ], default_value="not_ok")