Friday, 10 November 2017

Java Application monitoring with Prometheus

This is third blog post in series of Monitoring with Prometheus. When it comes to monitoring we all want to monitor how much CPU ,Memory etc used by each process.Basically node exporter will export metrics for hardware and OS exposed by *NIX kernels.But with Text file exporter we can achieve application monitoring with some shell scripts.

Here’s just a sample shell script which collect CPU,Memory and STATUS of particular process and export these logs to prometheus server.The fancy name we can have for script is Create Metrics directory and store all our metrics file in directory.

echo "Custom exporter for process $1"
while true
echo "Get Process ID"
Prometheus_ID=`ps -ef|grep $1|grep -v 'grep'|grep -v 'process_exporter'|awk '{print $2}'`
Prometheus_MEMORY_Value=`top -b -n 1|grep $Prometheus_ID |awk '{print $10}'`
echo "Process Status"
Prometheus_STATUS=`ps -p $Prometheus_ID|echo $?`
Prometheus_CPU_Value=`top -b -n 5|grep $Prometheus_ID |awk '{print $9}'|sort|head -1`
echo ""$Process_Name"_MEMORY_Usage "$Prometheus_MEMORY_Value"
"$Process_Name"_CPU_Usage "$Prometheus_CPU_Value"
"$Process_Name"_STATUS "$Prometheus_STATUS"" > Metrics/"$Process_Name"_Metrics.prom
sleep 10s

Suppose, you want to monitor java process then you can pass process name as parameter to this script.

Running script: java

It will create file named java_Metrics.prom in Metrics directory .It will look something like:
java_MEMORY_Usage 12
java_CPU_Usage 35
java_STATUS 0

We need to restart our node_exporter and pass path of Metrics directory to it as textfile collector.

Restart node Exporter:

After this the node exporter will export all these files data to prometheus server.
Check metrics in your prometheus dashboard.

You can write your own exporter and have metrics in prometheus dashboard.Prometheus makes it easy for us to monitor application metrics .You can also setup alerts CPU usage of particular service running on server goes above threshold value.


  1. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted "Oracle Training in Bangalore".

    1. Great Article android based projects

      Java Training in Chennai

      Project Center in Chennai

      Java Training in Chennai

      projects for cse

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training in India . Nowadays Java has tons of job opportunities on various vertical industry.

  3. And indeed, I’m just always astounded concerning the remarkable things served by you. Some four facts on this page are undeniably the most effective I’ve had.
    java-training in chennai

  4. Yup, I got this right, I guess. To get this clear, I can barely call myself as an experienced backender, if speaking of java itslef, because I'm on my top of the learning beginning yet, so I'm clear for sure with the fundamentals only. At this moment it works out quite nice to me to get all the theory on Java by these web courses, where I'm able to get the clear answers on a little unclear quetsions, like what to choose with no programming background to begin with, java or javascript Now it seems to me that I'm progressing pretty fast, so I think it's the time to start on more difficult stuff, like app monitoring here)

  5. very interesting article. i can learn more about java. very purposeful datas. best java training in chennai

  6. For any management professionals, some of the skills that are required include being able to manage personnel, organizational design and communication, and financial analysis and decision making. Gigabyte B360M DS3H review

  7. Thank you for sharing your article. Great efforts put it to find the list of articles which is very useful to know, Definitely will share the same to other forums.


  8. I am not aware of the common mistakes that drive online shoppers away from the E-commerce website. The checklist you have shared in the site is very much informative and helps to avoid the mistakes in E-commerce development.
    Hire Web Developer
    Hire Magento Developer
    Hire Wordpress Developer
    Mobile App Development India
    Hire Opencart Developer

  9. keep up the good work. this is an Assam post. this to helpful, i have reading here all post. i am impressed. thank you. this is our digital marketing training center. This is an online certificate course
    digital marketing training in bangalore |

  10. Worth reading! Our experts also have given detailed inputs about these trainings & courses! Presenting here for your reference. Do checkout
    oracle training in chennai & enjoy learning more about it.

  11. Worth reading! Our experts also have given detailed inputs about these trainings & courses! Presenting here for your reference. Do checkout Big data training in chennai & enjoy learning more about it.


Amazon EKS - Kubernetes on AWS

By Komal Devgaonkar Amazon Elastic Container Service for Kubernetes (Amazon EKS), which is highly available and scalable AWS service....