Aside: you might also want to look at kube-state-metrics 
<https://github.com/kubernetes/kube-state-metrics>, which can give you a 
range of pod metrics 
<https://github.com/kubernetes/kube-state-metrics/blob/main/docs/pod-metrics.md>
 
including the pod start time. Then an expression like 
time()-kube_pod_start_time should give you the pod age.

On Tuesday, 28 February 2023 at 17:55:20 UTC Brian Candler wrote:

> The problem is that the filename must end with ".prom", i.e. you need to 
> create "apt1.prom" not "apt1-prom"
>
> Also, you need to enable the functionality with a flag to node_exporter:
>
>     node_exporter --collector.textfile.directory=/var/lib/node_exporter
>
> See the documentation here: 
> https://github.com/prometheus/node_exporter#textfile-collector
>
> On Tuesday, 28 February 2023 at 17:16:06 UTC Stuart Clark wrote:
>
>> On 28/02/2023 17:12, BHARATH KUMAR wrote: 
>> > Hello All, 
>> > 
>> > I want to calculate the pod age running on every server. I wrote a 
>> > shell script. I added this script under the folder 
>> /var/lib/node_exporter. 
>> > 
>> > I created a cronjob for this script to run every minute 
>> > * * * * * root bash /var/lib/node_exporter/custom_metrics.sh > 
>> > /var/lib/node_exporter/apt1-prom 
>> > 
>> > I store the above cronjob in the /etc/cron.d folder with filename: 
>> > prom-apt1. 
>> > 
>> > But I am not able to see the metrics I created in Prometheus UI. 
>> > 
>> > 
>> > 
>> > But similarly, I created another shell script file to fetch some 
>> > metrics. I followed the same procedure as above. 
>> > 
>> > * * * * * root bash /var/lib/node_exporter/custom1.sh > 
>> > /var/lib/node_exporter/apt-prom 
>> > 
>> > I store the above cronjob in the /etc/cron.d folder with filename: 
>> > prom-apt. 
>> > 
>> > The metrics which I mentioned in custom1.sh, I am able to see those 
>> > metrics in Prometheus UI. 
>> > 
>> > 
>> > Could anyone help me? 
>> > 
>> What is the contents of those files in /var/lib/node_exporter? 
>>
>> -- 
>> Stuart Clark 
>>
>>

-- 
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/84408ccb-6753-41ec-94db-95cc404baa6en%40googlegroups.com.

Reply via email to