<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Narendiran D on Medium]]></title>
        <description><![CDATA[Stories by Narendiran D on Medium]]></description>
        <link>https://medium.com/@narendirand11?source=rss-c9d77755042b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*v9DHAX3JjgDPUEfpN-oGLg.jpeg</url>
            <title>Stories by Narendiran D on Medium</title>
            <link>https://medium.com/@narendirand11?source=rss-c9d77755042b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 23:22:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@narendirand11/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[OSRM data generation and deployment]]></title>
            <link>https://medium.com/logistimo-engineering-blog/osrm-data-generation-and-deployment-2f5a66269342?source=rss-c9d77755042b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f5a66269342</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[openstreetmap]]></category>
            <category><![CDATA[maps]]></category>
            <category><![CDATA[osrm]]></category>
            <category><![CDATA[routing]]></category>
            <dc:creator><![CDATA[Narendiran D]]></dc:creator>
            <pubDate>Tue, 23 Jun 2020 09:32:20 GMT</pubDate>
            <atom:updated>2020-06-25T07:01:35.691Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fhbkyl9rQ5qw9MjarB1YZg.png" /><figcaption>Open Source Routing Machine</figcaption></figure><p>The Open Source Routing Machine (OSRM) is an open-source router designed for use with data from the OpenStreetMap project. The following services are available via HTTP API, C++ library interface and NodeJs wrapper:</p><ul><li>Nearest — Snaps coordinates to the street network and returns the nearest matches</li><li>Route — Finds the fastest route between coordinates</li><li>Table — Computes the duration or distances of the fastest route between all pairs of supplied coordinates</li><li>Match — Snaps noisy GPS traces to the road network in the most plausible way</li><li>Trip — Solves the Traveling Salesman Problem using a greedy heuristic</li><li>Tile — Generates Mapbox Vector Tiles with internal routing metadata</li></ul><h4>Why OpenStreetMap over Google Maps ?</h4><p>Open Street Maps (OSM) is an open source project maintained by the OpenStreetMap Community that provides free editable maps of the whole world. The most obvious advantage in using OpenStreetMap-based software over a commercial solution is economical convenience, because OpenStreetMap comes as free software.</p><p>The downside is that it takes a little configuration in order to setup a working web service. The easiest and quickest way to setup your own routing engine is to use Docker images</p><p>There are two pre-processing pipelines available:</p><ul><li>Contraction Hierarchies (CH)</li><li>Multi-Level Dijkstra (MLD)</li></ul><p>We recommend using MLD by default except for special use-cases such as very large distance matrices where CH is still a better fit for the time being. In the following we explain the MLD pipeline. If you want to use the CH pipeline instead replace osrm-partition and osrm-customize with a single osrm-contract and change the algorithm option for osrm-routed to --algorithm ch.</p><h4>Generate data using Docker:</h4><p>Our web service will be based on a map export from OpenStreetMap. There are several possible ways to obtain a map export.</p><p>The first option is to point your browser to the OpenStreetMap’s <a href="http://www.openstreetmap.org/export">export page</a>, zoom on the interested area, and click on Export. (You may need to use one of the other sources if the native export does not work; Overpass API is a good choice.) This will allow you to finely choose which areas to include in your map and, in general, to cut down on the pre-processing times.</p><p><a href="https://www.openstreetmap.org/export#map=6/16.225/73.059">https://www.openstreetmap.org/export#map=6/16.225/73.059</a></p><p>However, there are limits on the size of the export you can get from the OSRM website, so you might want to download a ready-made export. A number of services, such as <a href="http://download.geofabrik.de/">Geofabrik</a> and <a href="https://mapzen.com/metro-extracts">Mapzen</a> offer updated and ready-made map exports of countries and selected metropolitan areas, which are good for most use cases.</p><p>In this article we will see how the OSRM data is generated for India using MLD pipeline.</p><p>To generate the routing data you need to download the <strong>.<em>pbf</em> </strong>file for India from <a href="http://download.geofabrik.de/">Geofabrik</a>.</p><pre><em>wget http://download.geofabrik.de/asia/india-latest.osm.pbf</em></pre><p>OSM data comes in a variety of formats including XML and PBF, and contain a plethora of data. The data includes information which is irrelevant to routing, such as positions of public waste baskets. Also, the data does not conform to a hard standard and important information can be described in various ways. Thus it is necessary to extract the routing data into a normalized format. This is done by the OSRM tool named extractor.</p><p><a href="https://github.com/Project-OSRM/osrm-backend/wiki/Profiles">Profiles</a> are used during this process to determine what can be routed along, and what cannot (private roads, barriers etc.).</p><p>For the MLD pipeline we need to extract (osrm-extract) a graph out of the OpenStreetMap base map</p><pre><em>docker run -t -v $(pwd):/data osrm/osrm-backend:latest osrm-extract -p /opt/car.lua /data/india-latest.osm.pbf</em></pre><p>The flag -v $(pwd):/data creates the directory /data inside the docker container and makes the current working directory $(pwd) available there. The file /data/india-latest.osm.pbf inside the container is referring to $(pwd)/india-latest.osm.pbf on the host</p><p>Then partition (osrm-partition) this graph recursively into cells, by using the following command</p><pre><em>docker run -t -v $(pwd):/data osrm/osrm-backend:latest osrm-partition /data/india-latest.osrm</em></pre><p>Note that india-latest.osrm has a different file extension.</p><p>Once the graph is partitioned in to cells, customize the cells (osrm-customize) by calculating routing weights for all cells</p><pre>docker run -t -v $(pwd):/data osrm/osrm-backend:latest osrm-customize /data/india-latest.osrm</pre><p>For CH the partition and customize pipeline stage gets replaced by adding shortcuts from the Contraction Hierarchies algorithm (osrm-contract)</p><p>Once the graph is customized, then spawning up the development HTTP server (osrm-routed) responding to queries</p><h4>OSRM Docker Deployment</h4><p>Docker image can be run standalone without Kubernetes</p><pre>docker run -t -i -p 5000:5000 -v $(pwd):/data -d osrm/osrm-backend:latest osrm-routed — algorithm mld /data/india-latest.osrm</pre><p>Make requests against the HTTP server</p><p>Optionally start a user-friendly frontend on port 9966, and open it up in your browser</p><pre><em>docker run -p 9966:9966 osrm/osrm-frontend</em></pre><h4>OSRM Kubernetes Deployment</h4><p>To deploy the OSRM in Kubernetes cluster, we need the routing data inside the Kubernetes cluster. There are multiple ways to achieve this. The reliable way is to use persistent volume model in a dynamic Kubernetes cluster. On a standalone k8s cluster the simple and easiest way is to use the hostPath.</p><p>To deploy on standalone cluster once the data generation is completed, copy all the generated files to the following location <strong><em>/data/osrm/india</em></strong> on the server. Make sure this data is available on all the Kubernetes nodes.</p><p>Now use the below mentioned YAML file to deploy the osrm-backend application in k8s.</p><p><em>osrm-backend-india.yaml</em></p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: osrm-india<br>  labels:<br>    app: osrm-india<br>spec:<br>  ports:<br>  - port: 5000<br>    targetPort: 5000<br>    name: http<br>  selector:<br>    app: osrm-india<br>  type: NodePort<br>---<br>apiVersion: extensions/v1beta1<br>kind: Deployment<br>metadata:<br>  name: osrm-india<br>spec:<br>  replicas: 1<br>  template:<br>    metadata:<br>      labels:<br>        app: osrm-india<br>    spec:<br>      containers:<br>      - name: osrm-india<br>        image: osrm-backend:latest<br>        command: [&quot;/bin/sh&quot;, &quot;-c&quot;]<br>        args: [&quot;osrm-routed --algorithm mld /data/india-latest.osm.pbf&quot;]<br>        ports:<br>        - containerPort: 5000<br>          name: osrm-port<br>        volumeMounts:<br>        - name: india<br>          readOnly:  true<br>          mountPath: /data<br>      volumes:<br>      - name: india<br>        hostPath:<br>          path: /data/osrm/india<br>        resources:<br>          requests:<br>            memory: &quot;512Mi&quot;<br>            cpu: &quot;0.5&quot;<br>          limits:<br>            memory: &quot;512Mi&quot;<br>            cpu: &quot;0.5&quot;</pre><p>Below config make sure the data is mounted to the docker container while deploying</p><pre>        volumeMounts:<br>        - name: india<br>          readOnly:  true<br>          mountPath: /data<br>      volumes:<br>      - name: india<br>        hostPath:<br>          path: /data/osrm/india</pre><p>Command to run the osrm-backend image in Kubernetes</p><pre>kubectl apply -f <em>osrm-india.yaml</em></pre><p>To deploy the user-facing frontend with map, apply the below file</p><p><em>osrm-frontend.yaml</em></p><pre>kind: Service<br>metadata:<br>  name: osrm-frontend<br>  labels:<br>    app: osrm-frontend<br>spec:<br>  ports:<br>  - port: 9966<br>    targetPort: 9966<br>    name: http<br>  selector:<br>    app: osrm-frontend<br>  type: NodePort<br>---<br>apiVersion: extensions/v1beta1<br>kind: Deployment<br>metadata:<br>  name: osrm-frontend<br>spec:<br>  replicas: 1<br>  template:<br>    metadata:<br>      labels:<br>        app: osrm-frontend<br>    spec:<br>      containers:<br>      - name: osrm-frontend<br>        image: osrm/osrm-frontend<br>        ports:<br>        - containerPort: 9966<br>          name: osrm-frontend<br>        env:<br>        - name: BACKEND<br>          value: &#39;<a href="http://osrm-backend:5000&#39;">http://osrm-india:5000&#39;</a></pre><p>Command to run the osrm-backend image in Kubernetes</p><pre>kubectl apply -f <em>osrm-frontend.yaml</em></pre><p><strong>Note:</strong></p><p>OSRM data can be generated for any countries. The data generation consumes lot of memory on your server based on the country . To generate OSRM data for India, docker runs consumes almost 7 GB of RAM on the server.</p><h4>Conclusion</h4><p>This blog covers the configuration and maintenance of a web service which can answer questions such as:</p><ul><li>What is the closest street to a given pair of coordinates?</li><li>What’s the best way to get from point A to point B?</li><li>How long does it take to get from point A to point B with a car, or by foot?</li></ul><h4><strong>References</strong></h4><ul><li><a href="https://download.geofabrik.de/">Geofabrik Download Server</a></li><li><a href="https://extract.bbbike.org/">BBBike extracts OpenStreetMap</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f5a66269342" width="1" height="1" alt=""><hr><p><a href="https://medium.com/logistimo-engineering-blog/osrm-data-generation-and-deployment-2f5a66269342">OSRM data generation and deployment</a> was originally published in <a href="https://medium.com/logistimo-engineering-blog">Logistimo Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Security checklist for Linux server]]></title>
            <link>https://medium.com/@narendirand11/security-checklist-for-linux-server-f2baa1319223?source=rss-c9d77755042b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2baa1319223</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[administration]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[servers]]></category>
            <dc:creator><![CDATA[Narendiran D]]></dc:creator>
            <pubDate>Thu, 31 Oct 2019 09:33:23 GMT</pubDate>
            <atom:updated>2019-11-04T08:32:50.999Z</atom:updated>
            <content:encoded><![CDATA[<h3>Security checklist for servers</h3><p>Most people assume that Linux is already secure, and that’s a false assumption. It’s important to know that the Linux operating system has so many distributions and each one will differ from the command line perspective, but the logic is the same. This article will help you to secure and harden the Linux server.</p><p>Following are the important hardening tips for your linux servers:</p><ul><li>Remove unnecessary services</li><li>Check for security on key files</li><li>Set strong password policy</li><li>Limit root access using SUDO</li><li>Only allow root to access CRON</li><li>Remote access and SSH basic settings</li><li>Disable Xwindow</li><li>Selinux (Security Enhanced Linux)</li><li>Minimize Package Instllation</li><li>Checking accounts for empty passwords</li><li>Monitor user activities</li><li>Install and configure fail2ban</li><li>Rootkit detection</li><li>Monitor system logs</li><li>Enable 2-factor authentication</li></ul><h4>1. Remove unnecessary services</h4><p>Hardening systems by eliminating unnecessary services can enhance security<br>and improve overall system performance. To begin, you first need to know<br>which services are running on your system. Since services run in various ways, there are several places to check.</p><pre><br>$ ps –ax   (will list all currently running processes)</pre><pre>$ ls –l /etc/rc.d/rc3.d/S*  (will show all start-up scripts (if you boot into graphics mode, replace rc3.d with rc5.d))</pre><pre>$ netstat –a   (will list all open ports)</pre><pre>$ chkconfig –list   (will show the current startup status of all processes known by chkconfig)</pre><p>Ideally, you should see only those ports that must be open to provide the<br>functionality required by the system.</p><h4>2. Check for security on key files</h4><ul><li>/etc/fstab: make sure the owner &amp; group are set to root.root and the<br>permissions are set to 0644 (-rw-r — r — )</li><li>verify that /etc/passwd, /etc/shadow &amp; /etc/group are all owned by ‘root’</li><li>verify that permissions on /etc/passwd &amp; /etc/group are rw-r — r — (644)</li><li>verify that permissions on /etc/shadow are r — — — — (400)</li></ul><h4>3. Set strong password policy</h4><p>Ensure the default system password policy matches your organization<br>password policy. These settings are stored in <em>/etc/login.defs</em> and should<br>minimally contain settings for the following. <br>PASS_MAX_DAYS 90<br>PASS_MIN_DAYS 6<br>PASS_MIN_LEN 14<br>PASS_WARN_AGE 7</p><h4>4. Limit root access using SUDO</h4><p>Sudo allows an administrator to provide certain users the ability to run some<br>commands as root, while logging all sudo activity. Sudo operates on a percommand basis. The sudoers file controls command access.</p><h4>5. Only allow root to access CRON</h4><p>The cron daemon is used to schedule processes. The crontab command is<br>used to create personal crontab entries for users or the root account. To<br>enhance security of the cron scheduler, you can establish the cron.deny and<br>cron.allow files to control use of the crontab. The following commands will<br>establish root as the only user with permission to add cron jobs.</p><pre>$ cd /etc/<br>$ /bin/rm -f cron.deny at.deny<br>$ echo root &gt;cron.allow<br>$ echo root &gt;at.allow<br>$ /bin/chown root:root cron.allow at.allow<br>$ /bin/chmod 400 cron.allow at.allow</pre><h4>6. Remote access and SSH basic settings</h4><p>Telnet is not recommended for remote access. Secure Shell (SSH) provides<br>encrypted telnet-like access and is considered a secure alternative to telnet.<br>However, older versions of SSH have vulnerabilities and should not be used.<br>To disable SSH version 1 and enhance the overall security of SSH, consider<br>making the following changes to your sshd_config file:</p><pre>Protocol 2<br>PermitRootLogin no<br>PermitEmptyPasswords no<br>Banner /etc/issue<br>IgnoreRhosts yes<br>RhostsAuthentication no<br>RhostsRSAAuthentication no<br>HostbasedAuthentication no<br>LoginGraceTime 1m (or less — default is 2 minutes)<br>SyslogFacility AUTH (provides logging under syslog AUTH)<br>AllowUser [list of users allowed access]<br>DenyUser [list of system accounts and others not allowed]<br>MaxStartups 10 (or less — use 1/3 the total number of remote users)</pre><p><strong>Note:</strong> MaxStartups refers to the max number of simultaneous unauthenticated connections. This setting can be helpful against a bruteforce<br>script that performs forking.</p><p>Running ssh on an alternate port will help you avoid port scanners that are looking for open port. You can block such brute-force ssh attacks with a package like denyhosts, which utilizes tcpwrappers.</p><p>Alternatively, use your iptables firewall (see below) to limit access by IP<br>address or host/domain name.</p><h4>7. Disable Xwindow</h4><p>X window can be a large security risk considering the many exploits for the<br>product and since its data flows unencrypted across networks. There is no need to run X Window desktops like KDE or GNOME on your dedicated LAMP server. To disable X11, open the file ‘/etc/inittab‘ and set run level to 3. If you wish to remove it completely from the system use the below command.</p><pre>$ yum groupremove “X Window System”</pre><h4>8. Selinux</h4><p>The Security-enhanced Linux kernel enforces mandatory access control<br>policies that confine user programs and system servers to the minimum amount of privilege they require to do their jobs. . This confinement mechanism operates independently of the traditional Linux access control mechanisms. Implementing SE Linux can have unexpected effects on a system, and you may find standard daemons won’t run properly, or at all, or logfiles may not be writable, or other similar effects that require detailed configuration of SE Linux Currently.</p><h4>9. Minimize package installation</h4><p>It’s recommended to avoid installing useless packages to avoid vulnerabilities in packages. This may minimize risk that compromise of one service may lead to compromise of other services. Find and remove or disable unwanted services from the server to minimize vulnerability.</p><h4>10. Checking accounts for empty passwords</h4><p>Any account having an empty password means its opened for unauthorized access to anyone on the web and it’s a part of security within a Linux server. So, you must make sure all accounts have strong passwords and no one has any authorized access. Empty password accounts are security risks and that can be easily hackable. To check if there were any accounts with empty password, use the following command.</p><pre>$ cat /etc/shadow | awk -F: ‘($2==””){print $1}’</pre><h4>11. Monitor user activities</h4><p>Its important to collect the information of each user activities and processes consumed by them and analyse them at a later time or in case if any kind of performance, security issues. But how we can monitor and collect user activities information.</p><p>There are two useful tools called <em>‘psacct‘ </em>and <em>‘acct‘ </em>are used for monitoring user activities and processes on a system. These tools runs in a system background and continuously tracks each user activity on a system and resources consumed by services such as Apache, MySQL, SSH, FTP, etc.</p><h4>12. Install and configure fail2ban</h4><p>Any service that is exposed to the network is a potential target in this way. Most Linux servers offer an SSH login via Port 22 for remote administration purposes. This port is a well-known port, therefore, it is often attacked by brute force attacks. If you pay attention to application logs for these services, you will often see repeated, systematic login attempts that represent brute-force attacks by users and bots alike. Fail2ban can mitigate this problem by creating rules that automatically alter your iptables firewall configuration based on a predefined number of unsuccessful login attempts.</p><h4>13. Rootkit detection</h4><p>There are many ways that your server can be compromised by remote systems and malicious softwares. It’s important that once you discovered the attack, you try to find out how. Knowing how the attacker got in can help you reduce the risk of future compromises. Few such Malwares and vulnerabilities are Rootkit, Backdoor and Exploit. Following blog will guide you on the configuration of Rootkit hunter.</p><p><a href="https://medium.com/logistimo-engineering-blog/a-way-to-detect-the-rootkits-and-exploits-in-centos-rhel-5b125a8d6a25">https://medium.com/logistimo-engineering-blog/a-way-to-detect-the-rootkits-and-exploits-in-centos-rhel-5b125a8d6a25</a></p><h4>14. Monitor system logs</h4><p>Logwatch is an application that helps with simple log management by daily analysing and reporting a short digest from activities taking place on your machine. This tool analyzes and generates daily reports on your system’s log activity.</p><h4>15. Enable 2-factor authentication</h4><p>Enabling 2-factor authentication for all the servers is not advisable. It can be configured on the jump host ( login box ) of the infrastructure. It acts as an additional security layer for your business, helping to address the vulnerabilities of a standard password-only approach</p><p><strong>References</strong></p><ul><li><a href="https://medium.com/logistimo-engineering-blog/a-way-to-detect-the-rootkits-and-exploits-in-centos-rhel-5b125a8d6a25">A way to detect the rootkits and exploits in CentOS/RHEL</a></li><li><a href="https://jumpcloud.com/daas-product/multi-factor-authentication/">Multi-Factor Authentication | JumpCloud</a></li><li><a href="https://www.digitalocean.com/community/tutorials/how-fail2ban-works-to-protect-services-on-a-linux-server">How Fail2Ban Works to Protect Services on a Linux Server | DigitalOcean</a></li><li><a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-use-logwatch-log-analyzer-and-reporter-on-a-vps">How To Install and Use Logwatch Log Analyzer and Reporter on a VPS | DigitalOcean</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2baa1319223" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tomcat JVM metrics monitoring using Prometheus in Kubernetes]]></title>
            <link>https://medium.com/logistimo-engineering-blog/tomcat-jvm-metrics-monitoring-using-prometheus-in-kubernetes-c313075af727?source=rss-c9d77755042b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c313075af727</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Narendiran D]]></dc:creator>
            <pubDate>Mon, 11 Feb 2019 13:02:56 GMT</pubDate>
            <atom:updated>2019-05-18T03:04:09.649Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ENTzvKobw86_5oDI78gT0w.png" /></figure><p>Monitoring metrics and runtime characteristics of an application server is essential to ensure the adequate functioning of the applications running on that server, as well as to prevent or resolve potential issues in a timely manner. As far as Java applications go, one of the most commonly used web application servers is Apache Tomcat, which will be the focus of this article.</p><p>Tomcat performance monitoring in Kubernetes cluster can be done either by relying on JMX beans or other tools available in the market. We have listed the prerequisite with which this monitoring can be achieved.</p><ol><li>Prometheus Agent</li><li>Kubernetes YAML for application</li><li>Annotations</li><li>Scraping Policy</li><li>Prometheus Server</li></ol><h4>Prometheus Agent</h4><p>Prometheus provides a collector that can scrape and expose the mBeans of a JMX target. It runs as a Java Agent, exposing an HTTP server and serving metrics of the local JVM. It can also be run as an independent HTTP server and scrape remote JMX targets, but this comes with various disadvantages, such as it being harder to configure and it being unable to expose process metrics (e.g., memory and CPU usage). Running the exporter as a Java Agent is thus strongly encouraged.</p><p>The following Dockerfile adds support for the options we’ve listed.</p><pre>FROM tomcat</pre><pre>RUN mkdir /data</pre><pre>ADD jmx_prometheus_javaagent-0.7-SNAPSHOT.jar /data/jmx_prometheus_javaagent-0.7-SNAPSHOT.jar</pre><pre>ADD prometheus-jmx-config.yaml /data/prometheus-jmx-config.yaml</pre><pre>CMD java -javaagent:/data/jmx_prometheus_javaagent-0.7.jar=8088:/data/prometheus-jmx-config.yaml -jar $TOMCAT_HOME/start.jar</pre><ul><li>Connect to an exposed JMX port of the JVM (not recommended)</li><li>Java agent version (recommended)</li></ul><p>If you use the agent version, you’ll have to modify three configuration options:</p><ul><li>the Jar file location</li><li>the port for the http(s) interface, where the metrics will be available for scraping, already in Prometheus friendly format</li><li>additional configuration options</li></ul><p>An example looks like this:</p><pre><em>-javaagent:/opt/jmx-exporter/</em>jmx_prometheus_javaagent-0.7.jar<em>=8088</em></pre><p>The latest jar can be downloaded from the following link:</p><pre>wget <a href="http://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.7/jmx_prometheus_javaagent-0.7.jar">http://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.7/jmx_prometheus_javaagent-&lt;latest-version&gt;.jar</a></pre><p>Create<em> prometheus-jmx-config.yaml with following config in it</em></p><pre>---<br>hostPort: 127.0.0.1:1234<br>lowercaseOutputName: false<br>lowercaseOutputLabelNames: false</pre><p>The complete options for the prometheus-jmx-config.yaml <em>is available </em><a href="https://github.com/prometheus/jmx_exporter"><em>here</em></a><em>.</em></p><h4>Kubernetes YAML for application</h4><p>When you run the tomcat image in Kubernetes infrastructure, the JMX port needs to be exposed to scrape the data from the container. Following sample tomcat YAML file shows how to deploy the basic tomcat service in K8s infrastructure with prometheus JMX port exposed and annotated.</p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: &lt;service name&gt;<br>  labels:<br>    app: &lt;service name&gt;<br>spec:<br>  ports:<br>  - port: 8080<br>    targetPort: 8080<br>    name: http<br>  - port: 8088<br>    targetPort: 8088<br>    name: prom<br>  selector:<br>    app: &lt;service name&gt;<br>  type: NodePort<br>---<br>apiVersion: extensions/v1beta1<br>kind: Deployment<br>metadata:<br>  name: &lt;deployment name&gt;<br>spec:<br>  # this replicas value is default<br>  # modify it according to your case<br>  replicas: 1<br>  template:<br>    metadata:<br>      labels:<br>        app: &lt;deployment name&gt;<br>        type: java<br>      annotations:<br>        prometheus.io/scrape: &#39;true&#39;<br>        prometheus.io/port: &#39;8088&#39;<br>    spec:<br>      containers:<br>      - name: &lt;container name&gt;<br>        image: &lt;docker image&gt;<br>        ports:<br>        - containerPort: 8080<br>        env:<br>        - name: JAVA_AGENT_PORT<br>          value: &quot;8088&quot;<br>        resources:<br>          requests:<br>            memory: &quot;1024Mi&quot;<br>            cpu: &quot;1&quot;<br>          limits:<br>            memory: &quot;1024Mi&quot;<br>            cpu: &quot;1&quot;</pre><h4>Annotations</h4><p>Annotations on pods allow a fine grained control of the scraping process:</p><ul><li>prometheus.io/scrape: The default configuration will scrape all pods and, if set to false, this annotation will exclude the pod from the scraping process.</li><li>prometheus.io/path: If the metrics path is not /metrics, define it with this annotation.</li><li>prometheus.io/port: Scrape the pod on the indicated port instead of the pod’s declared ports (default is a port-free target if none are declared).</li></ul><p>These annotations need to be part of the pod metadata. They will have no effect if set on other objects such as Services or DaemonSets. The above Deployment manifest will instruct Prometheus to scrape all of its pods on port 8088.</p><h4>Scraping Policy</h4><p>To minimise the amount of configuration required from the user, the default setup will try to scrape all pods present in the system. This may have some undesirable side-effects such as:</p><ul><li>Prometheus issuing HTTP GET requests to TCP ports not even exposing an HTTP server.</li><li>Prometheus issuing HTTP GET requests to fetch /metrics on services that may not export any metric, polluting logs.</li></ul><p>While the annotations described in the previous section allow the user to <strong>opt-out</strong> of the scraping process, we also offer an alternative Prometheus configuration that only scrapes a minimal set of system metrics and requires the user to <strong>opt-in</strong> on a per-pod basis. In other words, in this mode the prometheus.io/scrape: true annotation is required for Prometheus to scrape the pod.</p><p>Now that we have all the required configs in place to scrape the JVM data from the tomcat container. Let see how it can be scraped via prometheus server.</p><h4>Prometheus Server</h4><p>Prometheus is a monitoring platform that collects metrics from monitored targets by scraping metrics HTTP endpoints on these targets. Please use the following docker-compose.yaml for downloading the Prometheus Image</p><pre>---<br>version: &#39;2&#39;<br>services:<br>  prometheus:<br>    container_name: prometheus<br>    image: prom/prometheus:latest<br>    restart: always<br>    ports:<br>      - &quot;9090:9090&quot;<br>    volumes:<br>    - /data/prometheus/prometheus.yml:/prometheus/prometheus.yml:ro<br>    command: [ &#39;--config.file=/prometheus/prometheus.yml&#39;, &#39;--web.enable-lifecycle&#39;, &#39;--web.enable-admin-api&#39;, &#39;--storage.tsdb.retention=1y&#39; ]</pre><h4>Configuring Prometheus</h4><p>The Prometheus download comes with a sample configuration in a file called prometheus.yml</p><pre>global:<br>  scrape_interval:     15s<br>  evaluation_interval: 15s<br><br>rule_files:<br>  # - &quot;first.rules&quot;<br>  # - &quot;second.rules&quot;<br><br>scrape_configs:<br>  - job_name: &#39;prometheus<br>    scrape_interval: 30s<br>    kubernetes_sd_configs:<br>    - role: pod<br>      namespaces:<br>        names:<br>        - staging<br>    scheme: http<br>    relabel_configs:<br>    - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]<br>      action: keep<br>      regex: true<br>    - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]<br>      action: replace<br>      regex: ([^:]+)(?::\d+)?;(\d+)<br>      replacement: $1:$2<br>      target_label: __address__<br>    - action: labelmap<br>      regex: __meta_kubernetes_pod_label_(.+)<br>    - source_labels: [__meta_kubernetes_namespace]<br>      action: replace<br>      target_label: kubernetes_namespace<br>    - source_labels: [__meta_kubernetes_pod_name]<br>      action: replace<br>      target_label: kubernetes_pod_name</pre><p>There are three blocks of configuration in the example configuration file: global, rule_files, and scrape_configs.</p><ul><li>The global block controls the Prometheus server&#39;s global configuration. We have two options present. The first, scrape_interval, controls how often Prometheus will scrape targets. The evaluation_interval option controls how often Prometheus will evaluate rules.</li><li>The rule_files block specifies the location of any rules we want the Prometheus server to load. For now we&#39;ve got no rules.</li><li>The last block, scrape_configs, controls what resources Prometheus monitors. Since Prometheus also exposes data about itself as an HTTP endpoint it can scrape and monitor its own health. Prometheus expects metrics to be available on targets on a path of /metrics. So this default job is scraping via the URL: <a href="http://localhost:9090/metrics">http://&lt;hostname&gt;:9090/metrics</a>.</li></ul><p>When you scrape data from the containers running inside the Kubernetes cluster, don’t forget to mentions the namespace from where the data should be scraped as mentioned in the above config file.</p><p>Once you have all prerequisites configured and deployed, the JVM metrics will be collected and stored in the prometheus. We use Grafana to create a graphical dashboard and measure the performance as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EdamiGwYa_VLNhKHL-ksXA.png" /><figcaption>Kube JVM Metrics</figcaption></figure><p><strong>References</strong></p><ul><li><a href="https://grafana.com/dashboards/3066">JVM overview - Prometheus dashboard for Grafana</a></li><li><a href="https://github.com/prometheus/jmx_exporter">GitHub - prometheus/jmx_exporter: A process for collecting metrics using JMX MBeans for Prometheus consumption</a></li><li><a href="https://docs.docker.com/config/thirdparty/prometheus/">Collect Docker metrics with Prometheus</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c313075af727" width="1" height="1" alt=""><hr><p><a href="https://medium.com/logistimo-engineering-blog/tomcat-jvm-metrics-monitoring-using-prometheus-in-kubernetes-c313075af727">Tomcat JVM metrics monitoring using Prometheus in Kubernetes</a> was originally published in <a href="https://medium.com/logistimo-engineering-blog">Logistimo Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A way to detect the rootkits and exploits in CentOS/RHEL]]></title>
            <link>https://medium.com/logistimo-engineering-blog/a-way-to-detect-the-rootkits-and-exploits-in-centos-rhel-5b125a8d6a25?source=rss-c9d77755042b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b125a8d6a25</guid>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[malware]]></category>
            <category><![CDATA[virus]]></category>
            <dc:creator><![CDATA[Narendiran D]]></dc:creator>
            <pubDate>Mon, 29 Oct 2018 09:12:56 GMT</pubDate>
            <atom:updated>2019-01-10T06:59:12.017Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*tzW6lHG66V0rB4-7xAKx0Q.png" /></figure><p>There are many ways that your server can be compromised by remote systems and malicious softwares. It’s important that once you discovered the attack, you try to find out how. Knowing how the attacker got in can help you reduce the risk of future compromises. Few such malwares and vulnerabilities are rootkit, backdoor and exploit.</p><p><strong>Rootkits</strong> are softwares that can provide the administrative access to the servers. This malware can be planted into the targeted system by an attacker through following means:</p><ol><li>Network port</li><li>An un-patched system</li><li>System with a weak administrator password etc.</li></ol><p>Rootkits replace normal programs and system libraries that are part of the operating system on victim machines with versions that superficially appear to be normal, but that in reality subvert the security of the machine and cause malicious functions to be executed. This kind of attack does not usually trigger automated network security controls like intrusion detection systems. It can be discovered only by digging deep on the affected system for behavioural change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P4q7AVRA7JJUKx4otXQbiw.png" /></figure><p><strong>Backdoor</strong> is a means to access a computer system or encrypted data that bypasses the system’s security mechanisms. Attackers often use back-doors that they detect or install themselves as part of exploit. In some cases, a <a href="https://searchsecurity.techtarget.com/definition/worm">worm</a> or <a href="https://searchsecurity.techtarget.com/definition/virus">virus</a> is designed to take advantage of a backdoor created by an earlier attack. In simple words, the default password can function as back-doors if they are not changed by the user. Another example would be some debugging features that can also act as back-doors if they are not removed in the release version.</p><p><strong>Exploit</strong> is a piece of software, data or a sequence of commands that takes advantage of a bug or vulnerabilities to cause unanticipated behaviour. In simple words “<em>to use something for one’s own advantage”.</em></p><p><strong>rkhunter</strong> is a popular tool to detect such vulnerabilities and malwares . It can scan the entire system for rootkits and help us to defend ourselves against potential threats.</p><h3>rkhunter</h3><p><strong>rkhunter</strong> (<strong>Rootkit Hunter</strong>) is a Unix-based tool that scans for rootkits, backdoors and possible local exploits. It checks the system against a database of known rootkits as well as perform the following security checks:</p><ul><li>Compare MD5 hash</li><li>Look for default files used by rootkits</li><li>Check wrong file permissions for binaries</li><li>Look for suspected strings in LKM and KLD modules</li><li>Look for hidden files</li><li>Optional scan within plaintext and binary files</li></ul><h4>Install rkhunter on CentOS and RHEL</h4><p>All files required for installation of rkhunter are contained in the EPEL repository.</p><pre>$ yum install epel-release</pre><p>Once the EPEL repository is installed, issue the following commands as root to start the installation routine and for updating the database.</p><pre>$ sudo yum install rkhunter<br>$ rkhunter --update</pre><h4>Update system file properties</h4><p>This is a necessary step to establish a foundation database file to compare scans. On a clean install, the first run of <strong><em>propupd</em></strong> creates a new database file. On later scans, running the <strong><em>propupd</em></strong> command updates the database file. Update the database file when you are satisfied you have only trusted source system file changes.</p><pre>$ rkhunter --propupd</pre><h4>Automate Rootkit Hunter using CRON</h4><p>rkhunter can be setup to run checks every day so that we always have up-to-date information about intrusions. This can be accomplished by creating a cronjob.</p><p>Create a cron file in the following location <em>/etc/cron.daily/rkhunter.sh </em>and place the following script in the file.</p><pre>#!/bin/sh<br>(<br>/usr/local/bin/rkhunter --versioncheck<br>/usr/local/bin/rkhunter --update<br>/usr/local/bin/rkhunter --cronjob --report-warnings-only<br>) | /bin/mail -s &#39;rkhunter Daily Scan Report (PutYourServerNameHere)&#39; your@email.here</pre><p>Update the script with the email address to which the report should be sent.</p><ul><li>The --versioncheck checks if our threat definitions are up to date.</li><li>The --update option updates our threat definitions, if required.</li><li>The --cronjob option bypasses interactive key presses.</li></ul><p>Set execute permission on the file you have just created</p><pre>$ chmod 755 /etc/cron.daily/rkhunter.sh</pre><p>The cron utility will run once daily and a report will be sent via email. Emails will be sent only if issues/problems surface. Otherwise, no emails will be sent.</p><p><strong>Manual Scan</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*g-lFQPzOOM6lcPG6TG_sXQ.png" /></figure><p>You can initiate a manual scan by issuing the following command:</p><pre>rkhunter -c</pre><p>which runs rkhunter in interactive mode. In other words, when it gets to the end of a particular scan, you need to press ‘enter’ to continue. If you want to “auto-skip” interactive mode, add the -sk option:</p><pre>rkhunter -c -sk</pre><p>Your scan results will look as follows:</p><pre>System checks summary<br>=====================</pre><pre>File properties checks...<br>    Files checked: 130<br>    Suspect files: 0</pre><pre>Rootkit checks...<br>    Rootkits checked : 498<br>    Possible rootkits: 0</pre><pre>Applications checks...<br>    All checks skipped</pre><pre>The system checks took: 14 minutes and 34 seconds</pre><pre>All results have been written to the log file: /var/log/rkhunter/rkhunter.log</pre><pre>No warnings were found while checking the system.</pre><p><strong>Conclusion</strong></p><p>If a rootkit has been installed in a compromised system, rebuilding the system is the best course of action. Because rootkits are so proficient in hiding themselves. Extremely strong monitoring and intrusion-detection/intrusion-prevention efforts need to be implemented. This article serves as an introductory tutorial to detection of rootkits.</p><p><strong>References</strong></p><ul><li><a href="https://www.woktron.com/secure/knowledgebase/79/Installation-Rootkit-Hunter-rkhunter-on-CentOS-5-and-6.html">Knowledgebase</a></li><li><a href="https://searchsecurity.techtarget.com/definition/back-door">What is backdoor (computing)? - Definition from WhatIs.com</a></li><li><a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/intelligence/exploits-malware">Exploits and exploit kits</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b125a8d6a25" width="1" height="1" alt=""><hr><p><a href="https://medium.com/logistimo-engineering-blog/a-way-to-detect-the-rootkits-and-exploits-in-centos-rhel-5b125a8d6a25">A way to detect the rootkits and exploits in CentOS/RHEL</a> was originally published in <a href="https://medium.com/logistimo-engineering-blog">Logistimo Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Elastic APM in Kubernetes]]></title>
            <link>https://medium.com/logistimo-engineering-blog/how-did-i-use-apm-in-kubernetes-ecosystem-8f22d52beb03?source=rss-c9d77755042b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f22d52beb03</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[apm]]></category>
            <category><![CDATA[elk]]></category>
            <dc:creator><![CDATA[Narendiran D]]></dc:creator>
            <pubDate>Fri, 03 Aug 2018 06:36:41 GMT</pubDate>
            <atom:updated>2018-10-12T02:24:18.585Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>“If it isn’t monitored, it isn’t production!”</strong></blockquote><p>In a microservice environment handling huge workloads, a performance dip of a single microservice will mean the performance degradation of an entire application. A single weak link in the chain can endanger our SLAs. The SCM product at <a href="http://www.logistimo.com/">Logistimo</a> handles mission-critical public-health supply chains for host of countries, via an array of microservices. Since the vitality of these systems is important at many levels, we take monitoring performance very seriously.</p><p>Our microservices are managed in a Kubernetes (K8s) cluster. The K8s ecosystem provides an array of options to monitor health and performance of the services. However, we wanted a solution which could monitor the performance of the application at the micro-service level. This brought us to the use of Elastic APM for our Kubernetes cluster. APM stands for <strong><em>Application Performance Monitoring</em></strong>. Deploying Elastic APM in Kubernetes ecosystem is a topic on which not much literature is found on the web. Hence, We decided to share our experience.</p><h3>Elastic APM system:</h3><p>If you are using the ELK stack( <strong><em>Elasticsearch, Logstash and Kibana</em></strong> ) for log aggregation in your infrastructure, you might be recording all the application logs in the Elasticsearch. While this in itself is useful, It is necessary to have APM monitoring for microservices. Elastic APM streams all events to Elastic search much like the Logstash.</p><p>Since data is stored as raw documents in Elasticsearch, your service metrics can coexist with your infrastructure logs making it easy to explore all of your data in one place. These metrics can be visualised in Kibana with pre-configured dashboards.</p><p>To do this APM metrics collection, you need two components:</p><ol><li>APM server</li><li>APM agent</li></ol><h4><strong>APM server</strong></h4><p>APM Server is a central component in the Elastic APM system. It receives data from APM agents and transforms them into Elastic search documents</p><p>A single APM server can handle data from multiple microservices. APM Server works by exposing an HTTP server to which agents post the APM data they collect.</p><p>To deploy the basic APM Server in K8s infrastructure, you can use following <em>Kube-apm-server.yaml</em> file:</p><pre>---<br>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: apm-server-config<br>  labels:<br>    k8s-app: apm-server<br>data:<br>  apm-server.yml: |-<br>    apm-server:<br>      host: &quot;0.0.0.0:8200&quot;<br>      frontend:<br>        enabled: false<br>    setup.template.settings:<br>      index:<br>        number_of_shards: 1<br>        codec: best_compression<br>    setup.dashboards.enabled: true<br>    setup.kibana:<br>      host: &quot;&lt; kibana endpoint &gt;&quot;<br>    output.elasticsearch:<br>      hosts: [&quot;&lt; elasticsearch endpoint &gt;&quot;]<br>      indices:<br>        - index: &quot;apm-%{[beat.version]}-sourcemap&quot;<br>          when.contains:<br>            processor.event: &quot;sourcemap&quot;</pre><pre>- index: &quot;apm-%{[beat.version]}-error-%{+yyyy.MM.dd}&quot;<br>          when.contains:<br>            processor.event: &quot;error&quot;</pre><pre>- index: &quot;apm-%{[beat.version]}-transaction-%{+yyyy.MM.dd}&quot;<br>          when.contains:<br>            processor.event: &quot;transaction&quot;</pre><pre>- index: &quot;apm-%{[beat.version]}-span-%{+yyyy.MM.dd}&quot;<br>          when.contains:<br>            processor.event: &quot;span&quot;<br>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: apm-server<br>  labels:<br>    app: apm-server<br>spec:<br>  ports:<br>  - port: 8200<br>    targetPort: 8200<br>    name: http<br>    nodePort: 31000<br>  selector:<br>    app: apm-server<br>  type: NodePort<br>---<br>apiVersion: extensions/v1beta1<br>kind: Deployment<br>metadata:<br>  name: apm-server<br>spec:<br>  # this replicas value is default<br>  # modify it according to your case<br>  replicas: 1<br>  template:<br>    metadata:<br>      labels:<br>        app: apm-server<br>    spec:<br>      containers:<br>      - name: apm-server<br>        image: docker.elastic.co/apm/apm-server:6.3.1<br>        ports:<br>        - containerPort: 8200<br>          name: apm-port<br>        volumeMounts:<br>        - name: apm-server-config<br>          mountPath: /usr/share/apm-server/apm-server.yml<br>          readOnly: true<br>          subPath: apm-server.yml<br>      volumes:<br>      - name: apm-server-config<br>        configMap:<br>          name: apm-server-config</pre><blockquote>Replace the host: “&lt; Kibana endpoint &gt;” and hosts: [“&lt; Elasticsearch endpoint &gt;”] with end points.</blockquote><p>APM Server comes with predefined Kibana dashboards and index templates for APM data.</p><p>Following is the list of default dashboards available. You can also configure custom dashboards according to your needs.</p><ol><li>Transactions</li><li>Span Details</li><li>Services</li><li>Errors</li><li>Error Details</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vWV6P4XoCbF20xMnYys6RQ.png" /><figcaption>APM predefined Kibana dashboards</figcaption></figure><p>These dashboards give you an instant overview of application response times, requests per minutes, error occurrences and more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VOnts9LMsgecv438tqltDA.png" /><figcaption>Response time and Request per minute metric</figcaption></figure><h4>APM Agent</h4><p>The agents are libraries that run inside your application process. Agents automatically instrument your application in order to measure the duration of requests to your service. It also automatically measures things like database queries, cache calls, external http requests and errors. Ensure you add APM agent to all of your micro services to get the metrics.</p><p><strong><em>APM agent for Dockerized Java application:</em></strong></p><p>The first step in getting started with the Elastic APM Java agent is to download the latest release of the agent jar file from <a href="http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22co.elastic.apm%22%20AND%20a%3A%22elastic-apm-agent%22">maven central</a>.</p><p>Add the following code in your Dockerfile to download and set the javaagent environment variable at the build time of the microservice.</p><pre>RUN wget -P &lt; $TOMCAT_HOME/ &gt; <a href="http://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/">http://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/</a>&lt;latest-version&gt;/elastic-apm-agent-&lt;latest-version&gt;.jar</pre><pre>ENV JAVA_OPTS=-javaagent:$TOMCAT_HOME/elastic-apm-agent-&lt; elastic-apm.version &gt;.jar</pre><p>Elastic APM agent has lot of configuration options.The most important ones are <em>service_name (required), server_url,</em> and <em>application_packages.</em></p><pre>System properties:</pre><pre>-Delastic.apm.service_name=my-service<br>-Delastic.apm.application_packages=org.example<br>-Delastic.apm.server_url=<a href="http://localhost:8300/">http://localhost:8200</a></pre><p>The complete Dockerfile entry for apm-agent will look like this</p><pre>RUN cd $TOMCAT_HOME &amp;&amp; wget <a href="http://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/">http://repo1.maven.org/maven2/co/elastic/apm/elastic-apm-agent/</a>&lt;latest-version&gt;/elastic-apm-agent-&lt;latest-version&gt;.jar<br> </pre><pre>ENV JAVA_OPTS=-javaagent:$TOMCAT_HOME/elastic-apm-agent-&lt;latest-version&gt;.jar \<br>              -Delastic.apm.service_name=&lt; Service name &gt; \<br>              -Delastic.apm.application_packages=&lt; application pakage name &gt; \<br>              -Delastic.apm.server_url=&lt; APM server url/endpoint &gt;</pre><p>The service name is used by Elastic APM to differentiate data coming from different services and to group data coming from the same services. When configuring an agent, you need to supply a service name.</p><p>The service name can only contain alphanumeric characters, spaces, underscores, and dashes (must match ^[a-zA-Z0–9 _-]+$).</p><p>You can set the Service Name and APM server url as the docker environmental variable as the value for these properties changes per environment you deploy.</p><p><strong><em>APM agent for Dockerized Node.js application</em></strong></p><p>In Dockerfile add the follwoing line</p><pre>RUN npm install elastic-apm-node --save</pre><p>Agent should be started before you mark other modules as dependency using require in your Node.js application . You will include the following code to enable agent in your application’s main file (usually <em>index.js, server.js or app.js</em>).</p><pre>// Add this to the VERY top of the first file loaded in your app<br>  var apm = require(&#39;elastic-apm-node&#39;).start({<br>    <br>    // Set required service name (allowed characters: a-z, A-Z, 0-9, -, _, and space)<br>    serviceName: &#39;&lt; Service Name&gt;&#39;,</pre><pre>// Use if APM Server requires a token<br>    secretToken: &#39;&lt; Secret token &gt;&#39;,</pre><pre>// Set custom APM Server URL (default: <a href="http://localhost:8200/">http://localhost:8200</a> )<br>    serverUrl: &#39;&lt; APM Server URL &gt;&#39;,<br>  })</pre><pre>var app = require(&#39;express&#39;)()</pre><p>Provided the correct value for the serviceName and serverUrl for the metrics to be collected.</p><h4>End Note:</h4><p>Elastic APM allowed us to avoid developing additional metering and instrumentation inside the micro services. APM agent takes care of monitoring all the key metrics. The data has been immensely useful for us to detect problems early and understand the state of the systems in production.</p><p>Happy Monitoring !!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f22d52beb03" width="1" height="1" alt=""><hr><p><a href="https://medium.com/logistimo-engineering-blog/how-did-i-use-apm-in-kubernetes-ecosystem-8f22d52beb03">Using Elastic APM in Kubernetes</a> was originally published in <a href="https://medium.com/logistimo-engineering-blog">Logistimo Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>