Hi 

I have a kubernetes cluster running in Amazon EKS, we are using the 
prometheus node-exporter docker image and running it as daemonset across 
all k8s nodes to fetch the node metrics. We had a use case to monitor the 
docker volumes usage on each node, I have written a shell script to fetch 
the data in the prometheus readable format

```
#! /bin/bash
hostip=$(curl -fs http://169.254.169.254/latest/meta-data/local-ipv4)

voulume_size=`df -Ph /var/lib/docker | awk '{if(NR>1)print $2}' | sed 
's/G//g'`
voulume_usage=`df -Ph /var/lib/docker | awk '{if(NR>1)print $5}' | sed 
's/%//g'`

`mkdir -p /home/ec2-user/node_exporter/textfile_collector`
`rm -f /home/ec2-user/node_exporter/textfile_collector/docker_volume.prom`

echo "# HELP _docker_volume_usage hostip usage." >> 
/home/ec2-user/node_exporter/textfile_collector/docker_volume.prom 2>&1
echo "# TYPE _docker_volume_usage gauge" >> 
/home/ec2-user/node_exporter/textfile_collector/docker_volume.prom 2>&1

echo "_docker_volume_usage{hostip=\"$hostip\",host=\"`hostname`\"} 
$voulume_usage" >> 
/home/ec2-user/node_exporter/textfile_collector/docker_volume.prom 2>&1


echo "# HELP _docker_volume_size hostip size." >> 
/home/ec2-user/node_exporter/textfile_collector/docker_volume.prom 2>&1
echo "# TYPE _docker_volume_size gauge" >> 
/home/ec2-user/node_exporter/textfile_collector/docker_volume.prom 2>&1

echo "_docker_volume_size{hostip=\"$hostip\",host=\"`hostname`\"} 
$voulume_size" >> 
/home/ec2-user/node_exporter/textfile_collector/docker_volume.prom 2>&1
```

I'm running the script on each node and adding the data to
*/home/ec2-user/node_exporter/textfile_collector/docker_volume.prom* file.

On the docker logs I see the below ERROR:
```
level=error ts=2021-01-21T08:44:45.125Z caller=textfile.go:197 
collector=textfile msg="failed to read textfile collector directory" 
path=/home/ec2-user/node_exporter/textfile_collector err="open 
/home/ec2-user/node_exporter/textfile_collector: no such file or directory"
```
Let me know where am I going wrong, I now had a doubt that whether the 
*textfile-collector* from the docker container colect data from the node in 
which the container is running! 

Any help over here would be appreciated.
Thanks,
Rohith Vallabhaneni.

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/bd449370-517d-45bd-ba80-6501088acc42n%40googlegroups.com.

Reply via email to