mirror of https://github.com/Icinga/icinga2.git
Graphite: Remove deprecated legacy schema mode
This commit includes some code cleanup too. fixes #4992
This commit is contained in:
parent
e188686ed4
commit
eb5e299c4b
|
@ -555,7 +555,6 @@ Configuration Attributes:
|
||||||
service_name_template |**Optional.** Metric prefix for service name. Defaults to "icinga2.$host.name$.services.$service.name$.$service.check_command$".
|
service_name_template |**Optional.** Metric prefix for service name. Defaults to "icinga2.$host.name$.services.$service.name$.$service.check_command$".
|
||||||
enable_send_thresholds | **Optional.** Send additional threshold metrics. Defaults to `false`.
|
enable_send_thresholds | **Optional.** Send additional threshold metrics. Defaults to `false`.
|
||||||
enable_send_metadata | **Optional.** Send additional metadata metrics. Defaults to `false`.
|
enable_send_metadata | **Optional.** Send additional metadata metrics. Defaults to `false`.
|
||||||
enable_legacy_mode | **Optional.** Enable legacy mode for schema < 2.4. **Note**: This will be removed in 2.8.
|
|
||||||
|
|
||||||
Additional usage examples can be found [here](14-features.md#graphite-carbon-cache-writer).
|
Additional usage examples can be found [here](14-features.md#graphite-carbon-cache-writer).
|
||||||
|
|
||||||
|
|
|
@ -165,8 +165,8 @@ expects the Graphite Carbon Cache to listen at `127.0.0.1` on TCP port `2003`.
|
||||||
|
|
||||||
#### Current Graphite Schema <a id="graphite-carbon-cache-writer-schema"></a>
|
#### Current Graphite Schema <a id="graphite-carbon-cache-writer-schema"></a>
|
||||||
|
|
||||||
The current naming schema is defined as follows. The official Icinga Web 2 Graphite
|
The current naming schema is defined as follows. The [Icinga Web 2 Graphite module](https://github.com/icinga/icingaweb2-module-graphite)
|
||||||
module will use that schema too.
|
depends on this schema.
|
||||||
|
|
||||||
The default prefix for hosts and services is configured using
|
The default prefix for hosts and services is configured using
|
||||||
[runtime macros](03-monitoring-basics.md#runtime-macros)like this:
|
[runtime macros](03-monitoring-basics.md#runtime-macros)like this:
|
||||||
|
@ -249,78 +249,6 @@ Cache.
|
||||||
pattern = ^icinga2\.
|
pattern = ^icinga2\.
|
||||||
retentions = 1m:2d,5m:10d,30m:90d,360m:4y
|
retentions = 1m:2d,5m:10d,30m:90d,360m:4y
|
||||||
|
|
||||||
#### Graphite Schema < 2.4 <a id="graphite-carbon-cache-writer-schema-legacy"></a>
|
|
||||||
|
|
||||||
> **Note**
|
|
||||||
>
|
|
||||||
> This legacy mode will be removed in 2.8.
|
|
||||||
|
|
||||||
In order to restore the old legacy schema, you'll need to adopt the `GraphiteWriter`
|
|
||||||
configuration:
|
|
||||||
|
|
||||||
object GraphiteWriter "graphite" {
|
|
||||||
|
|
||||||
enable_legacy_mode = true
|
|
||||||
|
|
||||||
host_name_template = "icinga.$host.name$"
|
|
||||||
service_name_template = "icinga.$host.name$.$service.name$"
|
|
||||||
}
|
|
||||||
|
|
||||||
The old legacy naming schema is
|
|
||||||
|
|
||||||
icinga.<hostname>.<metricname>
|
|
||||||
icinga.<hostname>.<servicename>.<metricname>
|
|
||||||
|
|
||||||
You can customize the metric prefix name by using the `host_name_template` and
|
|
||||||
`service_name_template` configuration attributes.
|
|
||||||
|
|
||||||
The example below uses [runtime macros](03-monitoring-basics.md#runtime-macros) and a
|
|
||||||
[global constant](17-language-reference.md#constants) named `GraphiteEnv`. The constant name
|
|
||||||
is freely definable and should be put in the [constants.conf](04-configuring-icinga-2.md#constants-conf) file.
|
|
||||||
|
|
||||||
const GraphiteEnv = "icinga.env1"
|
|
||||||
|
|
||||||
object GraphiteWriter "graphite" {
|
|
||||||
host_name_template = GraphiteEnv + ".$host.name$"
|
|
||||||
service_name_template = GraphiteEnv + ".$host.name$.$service.name$"
|
|
||||||
}
|
|
||||||
|
|
||||||
To make sure Icinga 2 writes a valid label into Graphite some characters are replaced
|
|
||||||
with `_` in the target name:
|
|
||||||
|
|
||||||
\/.- (and space)
|
|
||||||
|
|
||||||
The resulting name in Graphite might look like:
|
|
||||||
|
|
||||||
www-01 / http-cert / response time
|
|
||||||
icinga.www_01.http_cert.response_time
|
|
||||||
|
|
||||||
In addition to the performance data retrieved from the check plugin, Icinga 2 sends
|
|
||||||
internal check statistic data to Graphite:
|
|
||||||
|
|
||||||
metric | description
|
|
||||||
-------------------|------------------------------------------
|
|
||||||
current_attempt | current check attempt
|
|
||||||
max_check_attempts | maximum check attempts until the hard state is reached
|
|
||||||
reachable | checked object is reachable
|
|
||||||
downtime_depth | number of downtimes this object is in
|
|
||||||
acknowledgement | whether the object is acknowledged or not
|
|
||||||
execution_time | check execution time
|
|
||||||
latency | check latency
|
|
||||||
state | current state of the checked object
|
|
||||||
state_type | 0=SOFT, 1=HARD state
|
|
||||||
|
|
||||||
The following example illustrates how to configure the storage-schemas for Graphite Carbon
|
|
||||||
Cache. Please make sure that the order is correct because the first match wins.
|
|
||||||
|
|
||||||
[icinga_internals]
|
|
||||||
pattern = ^icinga\..*\.(max_check_attempts|reachable|current_attempt|execution_time|latency|state|state_type)
|
|
||||||
retentions = 5m:7d
|
|
||||||
|
|
||||||
[icinga_default]
|
|
||||||
# intervals like PNP4Nagios uses them per default
|
|
||||||
pattern = ^icinga\.
|
|
||||||
retentions = 1m:2d,5m:10d,30m:90d,360m:4y
|
|
||||||
|
|
||||||
### InfluxDB Writer <a id="influxdb-writer"></a>
|
### InfluxDB Writer <a id="influxdb-writer"></a>
|
||||||
|
|
||||||
|
|
|
@ -193,13 +193,9 @@ void GraphiteWriter::CheckResultHandlerInternal(const Checkable::Ptr& checkable,
|
||||||
if (!IcingaApplication::GetInstance()->GetEnablePerfdata() || !checkable->GetEnablePerfdata())
|
if (!IcingaApplication::GetInstance()->GetEnablePerfdata() || !checkable->GetEnablePerfdata())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Service::Ptr service = dynamic_pointer_cast<Service>(checkable);
|
|
||||||
Host::Ptr host;
|
Host::Ptr host;
|
||||||
|
Service::Ptr service;
|
||||||
if (service)
|
boost::tie(host, service) = GetHostService(checkable);
|
||||||
host = service->GetHost();
|
|
||||||
else
|
|
||||||
host = static_pointer_cast<Host>(checkable);
|
|
||||||
|
|
||||||
MacroProcessor::ResolverList resolvers;
|
MacroProcessor::ResolverList resolvers;
|
||||||
if (service)
|
if (service)
|
||||||
|
@ -209,57 +205,35 @@ void GraphiteWriter::CheckResultHandlerInternal(const Checkable::Ptr& checkable,
|
||||||
|
|
||||||
String prefix;
|
String prefix;
|
||||||
|
|
||||||
|
if (service) {
|
||||||
|
prefix = MacroProcessor::ResolveMacros(GetServiceNameTemplate(), resolvers, cr, NULL, boost::bind(&GraphiteWriter::EscapeMacroMetric, _1));
|
||||||
|
} else {
|
||||||
|
prefix = MacroProcessor::ResolveMacros(GetHostNameTemplate(), resolvers, cr, NULL, boost::bind(&GraphiteWriter::EscapeMacroMetric, _1));
|
||||||
|
}
|
||||||
|
|
||||||
|
String prefixPerfdata = prefix + ".perfdata";
|
||||||
|
String prefixMetadata = prefix + ".metadata";
|
||||||
|
|
||||||
double ts = cr->GetExecutionEnd();
|
double ts = cr->GetExecutionEnd();
|
||||||
|
|
||||||
/* new mode below. old mode in else tree with 2.4, deprecate it in 2.6, remove in 2.8 TODO */
|
if (GetEnableSendMetadata()) {
|
||||||
if (!GetEnableLegacyMode()) {
|
|
||||||
if (service) {
|
if (service) {
|
||||||
prefix = MacroProcessor::ResolveMacros(GetServiceNameTemplate(), resolvers, cr, NULL, boost::bind(&GraphiteWriter::EscapeMacroMetric, _1, false));
|
SendMetric(prefixMetadata, "state", service->GetState(), ts);
|
||||||
} else {
|
} else {
|
||||||
prefix = MacroProcessor::ResolveMacros(GetHostNameTemplate(), resolvers, cr, NULL, boost::bind(&GraphiteWriter::EscapeMacroMetric, _1, false));
|
SendMetric(prefixMetadata, "state", host->GetState(), ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
String prefix_perfdata = prefix + ".perfdata";
|
SendMetric(prefixMetadata, "current_attempt", checkable->GetCheckAttempt(), ts);
|
||||||
String prefix_metadata = prefix + ".metadata";
|
SendMetric(prefixMetadata, "max_check_attempts", checkable->GetMaxCheckAttempts(), ts);
|
||||||
|
SendMetric(prefixMetadata, "state_type", checkable->GetStateType(), ts);
|
||||||
if (GetEnableSendMetadata()) {
|
SendMetric(prefixMetadata, "reachable", checkable->IsReachable(), ts);
|
||||||
|
SendMetric(prefixMetadata, "downtime_depth", checkable->GetDowntimeDepth(), ts);
|
||||||
if (service) {
|
SendMetric(prefixMetadata, "acknowledgement", checkable->GetAcknowledgement(), ts);
|
||||||
SendMetric(prefix_metadata, "state", service->GetState(), ts);
|
SendMetric(prefixMetadata, "latency", cr->CalculateLatency(), ts);
|
||||||
} else {
|
SendMetric(prefixMetadata, "execution_time", cr->CalculateExecutionTime(), ts);
|
||||||
SendMetric(prefix_metadata, "state", host->GetState(), ts);
|
|
||||||
}
|
|
||||||
|
|
||||||
SendMetric(prefix_metadata, "current_attempt", checkable->GetCheckAttempt(), ts);
|
|
||||||
SendMetric(prefix_metadata, "max_check_attempts", checkable->GetMaxCheckAttempts(), ts);
|
|
||||||
SendMetric(prefix_metadata, "state_type", checkable->GetStateType(), ts);
|
|
||||||
SendMetric(prefix_metadata, "reachable", checkable->IsReachable(), ts);
|
|
||||||
SendMetric(prefix_metadata, "downtime_depth", checkable->GetDowntimeDepth(), ts);
|
|
||||||
SendMetric(prefix_metadata, "acknowledgement", checkable->GetAcknowledgement(), ts);
|
|
||||||
SendMetric(prefix_metadata, "latency", cr->CalculateLatency(), ts);
|
|
||||||
SendMetric(prefix_metadata, "execution_time", cr->CalculateExecutionTime(), ts);
|
|
||||||
}
|
|
||||||
|
|
||||||
SendPerfdata(prefix_perfdata, cr, ts);
|
|
||||||
} else {
|
|
||||||
if (service) {
|
|
||||||
prefix = MacroProcessor::ResolveMacros(GetServiceNameTemplate(), resolvers, cr, NULL, boost::bind(&GraphiteWriter::EscapeMacroMetric, _1, true));
|
|
||||||
SendMetric(prefix, "state", service->GetState(), ts);
|
|
||||||
} else {
|
|
||||||
prefix = MacroProcessor::ResolveMacros(GetHostNameTemplate(), resolvers, cr, NULL, boost::bind(&GraphiteWriter::EscapeMacroMetric, _1, true));
|
|
||||||
SendMetric(prefix, "state", host->GetState(), ts);
|
|
||||||
}
|
|
||||||
|
|
||||||
SendMetric(prefix, "current_attempt", checkable->GetCheckAttempt(), ts);
|
|
||||||
SendMetric(prefix, "max_check_attempts", checkable->GetMaxCheckAttempts(), ts);
|
|
||||||
SendMetric(prefix, "state_type", checkable->GetStateType(), ts);
|
|
||||||
SendMetric(prefix, "reachable", checkable->IsReachable(), ts);
|
|
||||||
SendMetric(prefix, "downtime_depth", checkable->GetDowntimeDepth(), ts);
|
|
||||||
SendMetric(prefix, "acknowledgement", checkable->GetAcknowledgement(), ts);
|
|
||||||
SendMetric(prefix, "latency", cr->CalculateLatency(), ts);
|
|
||||||
SendMetric(prefix, "execution_time", cr->CalculateExecutionTime(), ts);
|
|
||||||
SendPerfdata(prefix, cr, ts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SendPerfdata(prefixPerfdata, cr, ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphiteWriter::SendPerfdata(const String& prefix, const CheckResult::Ptr& cr, double ts)
|
void GraphiteWriter::SendPerfdata(const String& prefix, const CheckResult::Ptr& cr, double ts)
|
||||||
|
@ -285,35 +259,19 @@ void GraphiteWriter::SendPerfdata(const String& prefix, const CheckResult::Ptr&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* new mode below. old mode in else tree with 2.4, deprecate it in 2.6 */
|
String escapedKey = EscapeMetricLabel(pdv->GetLabel());
|
||||||
if (!GetEnableLegacyMode()) {
|
|
||||||
String escaped_key = EscapeMetricLabel(pdv->GetLabel());
|
|
||||||
|
|
||||||
SendMetric(prefix, escaped_key + ".value", pdv->GetValue(), ts);
|
SendMetric(prefix, escapedKey + ".value", pdv->GetValue(), ts);
|
||||||
|
|
||||||
if (GetEnableSendThresholds()) {
|
|
||||||
if (pdv->GetCrit())
|
|
||||||
SendMetric(prefix, escaped_key + ".crit", pdv->GetCrit(), ts);
|
|
||||||
if (pdv->GetWarn())
|
|
||||||
SendMetric(prefix, escaped_key + ".warn", pdv->GetWarn(), ts);
|
|
||||||
if (pdv->GetMin())
|
|
||||||
SendMetric(prefix, escaped_key + ".min", pdv->GetMin(), ts);
|
|
||||||
if (pdv->GetMax())
|
|
||||||
SendMetric(prefix, escaped_key + ".max", pdv->GetMax(), ts);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
String escaped_key = EscapeMetric(pdv->GetLabel());
|
|
||||||
boost::algorithm::replace_all(escaped_key, "::", ".");
|
|
||||||
SendMetric(prefix, escaped_key, pdv->GetValue(), ts);
|
|
||||||
|
|
||||||
|
if (GetEnableSendThresholds()) {
|
||||||
if (pdv->GetCrit())
|
if (pdv->GetCrit())
|
||||||
SendMetric(prefix, escaped_key + "_crit", pdv->GetCrit(), ts);
|
SendMetric(prefix, escapedKey + ".crit", pdv->GetCrit(), ts);
|
||||||
if (pdv->GetWarn())
|
if (pdv->GetWarn())
|
||||||
SendMetric(prefix, escaped_key + "_warn", pdv->GetWarn(), ts);
|
SendMetric(prefix, escapedKey + ".warn", pdv->GetWarn(), ts);
|
||||||
if (pdv->GetMin())
|
if (pdv->GetMin())
|
||||||
SendMetric(prefix, escaped_key + "_min", pdv->GetMin(), ts);
|
SendMetric(prefix, escapedKey + ".min", pdv->GetMin(), ts);
|
||||||
if (pdv->GetMax())
|
if (pdv->GetMax())
|
||||||
SendMetric(prefix, escaped_key + "_max", pdv->GetMax(), ts);
|
SendMetric(prefix, escapedKey + ".max", pdv->GetMax(), ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -345,7 +303,7 @@ void GraphiteWriter::SendMetric(const String& prefix, const String& name, double
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String GraphiteWriter::EscapeMetric(const String& str, bool legacyMode)
|
String GraphiteWriter::EscapeMetric(const String& str)
|
||||||
{
|
{
|
||||||
String result = str;
|
String result = str;
|
||||||
|
|
||||||
|
@ -355,9 +313,6 @@ String GraphiteWriter::EscapeMetric(const String& str, bool legacyMode)
|
||||||
boost::replace_all(result, "\\", "_");
|
boost::replace_all(result, "\\", "_");
|
||||||
boost::replace_all(result, "/", "_");
|
boost::replace_all(result, "/", "_");
|
||||||
|
|
||||||
if (legacyMode)
|
|
||||||
boost::replace_all(result, "-", "_");
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +329,7 @@ String GraphiteWriter::EscapeMetricLabel(const String& str)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Value GraphiteWriter::EscapeMacroMetric(const Value& value, bool legacyMode)
|
Value GraphiteWriter::EscapeMacroMetric(const Value& value)
|
||||||
{
|
{
|
||||||
if (value.IsObjectType<Array>()) {
|
if (value.IsObjectType<Array>()) {
|
||||||
Array::Ptr arr = value;
|
Array::Ptr arr = value;
|
||||||
|
@ -382,12 +337,12 @@ Value GraphiteWriter::EscapeMacroMetric(const Value& value, bool legacyMode)
|
||||||
|
|
||||||
ObjectLock olock(arr);
|
ObjectLock olock(arr);
|
||||||
for (const Value& arg : arr) {
|
for (const Value& arg : arr) {
|
||||||
result->Add(EscapeMetric(arg, legacyMode));
|
result->Add(EscapeMetric(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Utility::Join(result, '.');
|
return Utility::Join(result, '.');
|
||||||
} else
|
} else
|
||||||
return EscapeMetric(value, legacyMode);
|
return EscapeMetric(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphiteWriter::ValidateHostNameTemplate(const String& value, const ValidationUtils& utils)
|
void GraphiteWriter::ValidateHostNameTemplate(const String& value, const ValidationUtils& utils)
|
||||||
|
|
|
@ -64,9 +64,9 @@ private:
|
||||||
void CheckResultHandlerInternal(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
void CheckResultHandlerInternal(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
||||||
void SendMetric(const String& prefix, const String& name, double value, double ts);
|
void SendMetric(const String& prefix, const String& name, double value, double ts);
|
||||||
void SendPerfdata(const String& prefix, const CheckResult::Ptr& cr, double ts);
|
void SendPerfdata(const String& prefix, const CheckResult::Ptr& cr, double ts);
|
||||||
static String EscapeMetric(const String& str, bool legacyMode = false);
|
static String EscapeMetric(const String& str);
|
||||||
static String EscapeMetricLabel(const String& str);
|
static String EscapeMetricLabel(const String& str);
|
||||||
static Value EscapeMacroMetric(const Value& value, bool legacyMode = false);
|
static Value EscapeMacroMetric(const Value& value);
|
||||||
|
|
||||||
void ReconnectTimerHandler(void);
|
void ReconnectTimerHandler(void);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ class GraphiteWriter : ConfigObject
|
||||||
};
|
};
|
||||||
[config] bool enable_send_thresholds;
|
[config] bool enable_send_thresholds;
|
||||||
[config] bool enable_send_metadata;
|
[config] bool enable_send_metadata;
|
||||||
[config] bool enable_legacy_mode;
|
|
||||||
|
|
||||||
[no_user_modify] bool connected;
|
[no_user_modify] bool connected;
|
||||||
[no_user_modify] bool should_connect {
|
[no_user_modify] bool should_connect {
|
||||||
|
|
Loading…
Reference in New Issue