Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support graphite backend for telegraf in config-gui #507

Merged
merged 5 commits into from
Jul 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion net-mgmt/pfSense-pkg-Telegraf/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# $FreeBSD$

PORTNAME= pfSense-pkg-Telegraf
PORTVERSION= 0.4
PORTVERSION= 0.5
CATEGORIES= net-mgmt
MASTER_SITES= # empty
DISTFILES= # empty
Expand Down
14 changes: 14 additions & 0 deletions net-mgmt/pfSense-pkg-Telegraf/files/usr/local/pkg/telegraf.inc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ EOD;
$cfg .= "\toverwrite_template = false\n";
$cfg .= "\ttemplate_name = \"telegraf\"\n";
$cfg .= "\turls = [\"" . $telegraf_conf['elasticsearch_server'] . "\"]\n";
} else if ((is_array($telegraf_conf['telegraf_output']) && in_array("graphite", $telegraf_conf['telegraf_output'])) || $telegraf_conf['telegraf_output'] == "graphite") {
$cfg .= "[[outputs.graphite]]\n";
$cfg .= "\tservers = [\"" . $telegraf_conf['graphite_server'] . "\"]\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this not still be a problem if they failed to enter a server name? Or would graphite ignore that since it would be empty ([""])? If graphite will ignore the empty server rather than fail, it may be OK as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not deep into php development. I've aligned my proposal to the existing options.
It will behave the same as an empty inluxdb- server or an empty elastic-server server.

Copy link
Contributor

@W0CHP W0CHP May 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jim-p Hi Jim,

I helped out with the v1.6.1 Telegraf release recently: #517.
Telegraf will ignore [[outputs]] stanza configuration keys with no value (no errors/no bailing).

@thomasDOTde's changes work fine on my dev. instance, both with a Graphite host defined and not undefined.

Copy link

@PhilippWendler PhilippWendler Jun 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think this can be considered resolved? Is there anything else left to do?

if (!empty($telegraf_conf['graphite_prefix'])) {
$cfg .= "\tprefix = " . $telegraf_conf['graphite_prefix'] . "\n";
} else {
$cfg .= "\tprefix = \"monitor\"\n";
}
$cfg .= "\ttemplate = \"host.tags.measurement.field\"\n";
if (!empty($telegraf_conf['graphite_timeout'])) {
$cfg .= "\ttimeout = " . $telegraf_conf['graphite_timeout'] . "\n";
} else {
$cfg .= "\ttimeout = 2\n";
}
}
$conffile = "/usr/local/etc/telegraf.conf";
file_put_contents($conffile, $cfg);
Expand Down
19 changes: 19 additions & 0 deletions net-mgmt/pfSense-pkg-Telegraf/files/usr/local/pkg/telegraf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<options>
<option><name>InfluxDB</name><value>influxdb</value></option>
<option><name>ElasticSearch</name><value>elasticsearch</value></option>
<option><name>Graphite</name><value>graphite</value></option>
</options>
<multiple/>
</field>
Expand Down Expand Up @@ -95,6 +96,24 @@
<type>input</type>
<description>Full HTTP endpoint URL for ElasticSearch instance. E.g.: http://192.168.1.23:9200</description>
</field>
<field>
<fielddescr>*Graphite Server</fielddescr>
<fieldname>graphite_server</fieldname>
<type>input</type>
<description>Graphite Endpoint E.g.: host.fqdn:port</description>
</field>
<field>
<fielddescr>Graphite Prefix</fielddescr>
<fieldname>graphite_prefix</fieldname>
<type>input</type>
<description>Prefix to be used when submitting data to Graphite</description>
</field>
<field>
<fielddescr>Graphite Timeout</fielddescr>
<fieldname>graphite_timeout</fieldname>
<type>input</type>
<description>Timeout when submitting data to Graphite</description>
</field>
</fields>
<custom_php_resync_config_command>
telegraf_resync_config();
Expand Down