Reputation: 1
I can't send data to strackdriver. It's simple example. I'm using syntax what I found in example for collectd. Stackdriver documentation don't have info about how to send custom data from exec module. What am I doing wrong?
This is collectd.conf
LoadPlugin exec
<Plugin "exec">
Exec "apache" "/etc/stackdriver/collectd.d/dir.sh"
</Plugin>
This is dir.sh
#!/bin/bash
FOLDER="/var/www/"
while true; do
DU=$(du -shm ${FOLDER} | awk '{print $1}')
echo "PUTVAL \"projects/project_name/custom.googleapis.com/folder/completesolar\" interval=60 N:${DU}"
sleep 60
done
Script output
$/etc/stackdriver/collectd.d/dir.sh
PUTVAL "projects/project_name/custom.googleapis.com/folder/completesolar" interval:60 N:1155
I enabled debug mode and found this error:
[2018-09-21 00:45:55] utils_cmd_putval: handle_putval (fh = 0x3e71d8f040, buffer = PUTVAL "projects/project_name/custom.googleapis.com/folder/completesolar" interval=60 N:1155);
[2018-09-21 00:45:55] No such dataset registered: custom.googleapis.com/folder/completesolar
I created this metric and found it in stackdriver console: http://joxi.ru/a2XlPGvi1VzJL2
This is json for creating my metric:
{
"name": "projects/project_name/metricDescriptors/custom.googleapis.com/folder/completesolar",
"metricKind": "GAUGE",
"valueType": "DOUBLE",
"unit": "By",
"description": "Folder bytes used",
"displayName": "Folder usage",
"type": "custom.googleapis.com/folder/completesolar",
"metadata": {
"launchStage": "GA",
"samplePeriod": "60s",
"ingestDelay": "0s"
}
}
Upvotes: 0
Views: 2187
Reputation: 959
This should be work.
/etc/stackdriver/collectd.d/dir.conf
LoadPlugin exec
<Plugin "exec">
Exec "apache" "/path/to/dir.sh"
</Plugin>
LoadPlugin target_set
PreCacheChain "PreCache"
<Chain "PreCache">
<Rule "dir">
<Match regex>
Plugin "^exec$"
PluginInstance "^dir$"
</Match>
<Target "set">
MetaData "stackdriver_metric_type" "custom.googleapis.com/folder/completesolar"
# MetaData "stackdriver_metric_type" "custom.googleapis.com/%{plugin_instance}/%{type_instance}"
# MetaData "label:name" "dir usage"
</Target>
</Rule>
</Chain>
/path/to/dir.sh
#!/bin/bash
INTERVAL="$COLLECTD_INTERVAL"
HOSTNAME="$COLLECTD_HOSTNAME"
FOLDER="/var/www/"
while true; do
DU=$(du -sm ${FOLDER} | awk '{print $1}')
# https://collectd.org/documentation/manpages/collectd-exec.5.shtml
# PUTVAL Identifier [OptionList] Valuelist
# Identifier: <host>/<plugin>-<plugin_instance>/<type>-<type_instance>
# Type: See /opt/stackdriver/collectd/share/collectd/types.db
echo "PUTVAL ${HOSTNAME}/exec-dir/gauge-usage/ interval=${INTERVAL} N:${DU}"
sleep "${INTERVAL}"
done
See below if you want to (pre) create or delete a metric.
https://cloud.google.com/monitoring/custom-metrics/creating-metrics
Upvotes: 1
Reputation: 409
Looks like you are following this guide to ingest exec metrics. I think the rewrite rules did not work so the metric ends up being ingested though a regular agent metrics path, which rejects unrecognized metrics. You might need to modify the metadata for your metric by using filter chain . I would suggest you to revisit the troubleshooting guide.
Upvotes: 0