diff --git a/doc/09-object-types.md b/doc/09-object-types.md
index 78b59192c..b5779b9ae 100644
--- a/doc/09-object-types.md
+++ b/doc/09-object-types.md
@@ -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$".
enable_send_thresholds | **Optional.** Send additional threshold 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).
diff --git a/doc/14-features.md b/doc/14-features.md
index f99f7a757..0fa7cf62b 100644
--- a/doc/14-features.md
+++ b/doc/14-features.md
@@ -165,8 +165,8 @@ expects the Graphite Carbon Cache to listen at `127.0.0.1` on TCP port `2003`.
#### Current Graphite Schema
-The current naming schema is defined as follows. The official Icinga Web 2 Graphite
-module will use that schema too.
+The current naming schema is defined as follows. The [Icinga Web 2 Graphite module](https://github.com/icinga/icingaweb2-module-graphite)
+depends on this schema.
The default prefix for hosts and services is configured using
[runtime macros](03-monitoring-basics.md#runtime-macros)like this:
@@ -249,78 +249,6 @@ Cache.
pattern = ^icinga2\.
retentions = 1m:2d,5m:10d,30m:90d,360m:4y
-#### Graphite Schema < 2.4
-
-> **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..
- icinga...
-
-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
diff --git a/lib/perfdata/graphitewriter.cpp b/lib/perfdata/graphitewriter.cpp
index aaca7d8de..eb6db28b2 100644
--- a/lib/perfdata/graphitewriter.cpp
+++ b/lib/perfdata/graphitewriter.cpp
@@ -193,13 +193,9 @@ void GraphiteWriter::CheckResultHandlerInternal(const Checkable::Ptr& checkable,
if (!IcingaApplication::GetInstance()->GetEnablePerfdata() || !checkable->GetEnablePerfdata())
return;
- Service::Ptr service = dynamic_pointer_cast(checkable);
Host::Ptr host;
-
- if (service)
- host = service->GetHost();
- else
- host = static_pointer_cast(checkable);
+ Service::Ptr service;
+ boost::tie(host, service) = GetHostService(checkable);
MacroProcessor::ResolverList resolvers;
if (service)
@@ -209,57 +205,35 @@ void GraphiteWriter::CheckResultHandlerInternal(const Checkable::Ptr& checkable,
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();
- /* new mode below. old mode in else tree with 2.4, deprecate it in 2.6, remove in 2.8 TODO */
- if (!GetEnableLegacyMode()) {
+ if (GetEnableSendMetadata()) {
if (service) {
- prefix = MacroProcessor::ResolveMacros(GetServiceNameTemplate(), resolvers, cr, NULL, boost::bind(&GraphiteWriter::EscapeMacroMetric, _1, false));
+ SendMetric(prefixMetadata, "state", service->GetState(), ts);
} 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";
- String prefix_metadata = prefix + ".metadata";
-
- if (GetEnableSendMetadata()) {
-
- if (service) {
- SendMetric(prefix_metadata, "state", service->GetState(), ts);
- } else {
- 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);
+ SendMetric(prefixMetadata, "current_attempt", checkable->GetCheckAttempt(), ts);
+ SendMetric(prefixMetadata, "max_check_attempts", checkable->GetMaxCheckAttempts(), ts);
+ SendMetric(prefixMetadata, "state_type", checkable->GetStateType(), ts);
+ SendMetric(prefixMetadata, "reachable", checkable->IsReachable(), ts);
+ SendMetric(prefixMetadata, "downtime_depth", checkable->GetDowntimeDepth(), ts);
+ SendMetric(prefixMetadata, "acknowledgement", checkable->GetAcknowledgement(), ts);
+ SendMetric(prefixMetadata, "latency", cr->CalculateLatency(), ts);
+ SendMetric(prefixMetadata, "execution_time", cr->CalculateExecutionTime(), ts);
}
+
+ SendPerfdata(prefixPerfdata, cr, 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 */
- if (!GetEnableLegacyMode()) {
- String escaped_key = EscapeMetricLabel(pdv->GetLabel());
+ String escapedKey = EscapeMetricLabel(pdv->GetLabel());
- SendMetric(prefix, escaped_key + ".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);
+ SendMetric(prefix, escapedKey + ".value", pdv->GetValue(), ts);
+ if (GetEnableSendThresholds()) {
if (pdv->GetCrit())
- SendMetric(prefix, escaped_key + "_crit", pdv->GetCrit(), ts);
+ SendMetric(prefix, escapedKey + ".crit", pdv->GetCrit(), ts);
if (pdv->GetWarn())
- SendMetric(prefix, escaped_key + "_warn", pdv->GetWarn(), ts);
+ SendMetric(prefix, escapedKey + ".warn", pdv->GetWarn(), ts);
if (pdv->GetMin())
- SendMetric(prefix, escaped_key + "_min", pdv->GetMin(), ts);
+ SendMetric(prefix, escapedKey + ".min", pdv->GetMin(), ts);
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;
@@ -355,9 +313,6 @@ String GraphiteWriter::EscapeMetric(const String& str, bool legacyMode)
boost::replace_all(result, "\\", "_");
boost::replace_all(result, "/", "_");
- if (legacyMode)
- boost::replace_all(result, "-", "_");
-
return result;
}
@@ -374,7 +329,7 @@ String GraphiteWriter::EscapeMetricLabel(const String& str)
return result;
}
-Value GraphiteWriter::EscapeMacroMetric(const Value& value, bool legacyMode)
+Value GraphiteWriter::EscapeMacroMetric(const Value& value)
{
if (value.IsObjectType()) {
Array::Ptr arr = value;
@@ -382,12 +337,12 @@ Value GraphiteWriter::EscapeMacroMetric(const Value& value, bool legacyMode)
ObjectLock olock(arr);
for (const Value& arg : arr) {
- result->Add(EscapeMetric(arg, legacyMode));
+ result->Add(EscapeMetric(arg));
}
return Utility::Join(result, '.');
} else
- return EscapeMetric(value, legacyMode);
+ return EscapeMetric(value);
}
void GraphiteWriter::ValidateHostNameTemplate(const String& value, const ValidationUtils& utils)
diff --git a/lib/perfdata/graphitewriter.hpp b/lib/perfdata/graphitewriter.hpp
index 02eb849bd..98090850f 100644
--- a/lib/perfdata/graphitewriter.hpp
+++ b/lib/perfdata/graphitewriter.hpp
@@ -64,9 +64,9 @@ private:
void CheckResultHandlerInternal(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
void SendMetric(const String& prefix, const String& name, double value, 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 Value EscapeMacroMetric(const Value& value, bool legacyMode = false);
+ static Value EscapeMacroMetric(const Value& value);
void ReconnectTimerHandler(void);
diff --git a/lib/perfdata/graphitewriter.ti b/lib/perfdata/graphitewriter.ti
index 270635886..644b5d0a5 100644
--- a/lib/perfdata/graphitewriter.ti
+++ b/lib/perfdata/graphitewriter.ti
@@ -40,7 +40,6 @@ class GraphiteWriter : ConfigObject
};
[config] bool enable_send_thresholds;
[config] bool enable_send_metadata;
- [config] bool enable_legacy_mode;
[no_user_modify] bool connected;
[no_user_modify] bool should_connect {