# Elastic APM Node doing hits again and again

**URL:** <https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844>\
**Category:** APM\
**Tags:** nodejs, server\
**Created:** [August 9, 2021, 5:07pm UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844 "2021-08-09T17:07:07Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Piyush\_Mittal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/piyush_mittal/32/92656_2.png) [@Piyush\_Mittal](https://discuss.elastic.co/u/Piyush_Mittal)\
**Post date:** [August 9, 2021, 5:07pm UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844/1 "2021-08-09T17:07:07Z")

</div>

I created an simple nodejs application and trying to monitoring the API using elastic-node-apm package and visualize it using kibana but when I check the discover tab of my kibana dashboard I found that my elastic-node-apm hitting again and again a request after every 30 seconds. I don't have any idea why this happening if anyone has any idea Why this is happening please tell here.

**Here is my code in my nodejs application :**

```auto
const apm = require("elastic-apm-node").start({
  serviceName: "nodeAPMSerivce",
  serverUrl: "http://localhost:8200",
});

const express = require("express");
const connectDB = require("./config/db");
const dotenv = require("dotenv");
const User = require("./models/userModel");

dotenv.config();

const app = express();

connectDB();

app.use(express.json());

app.get("/", (req, res) => {
  res.send("Hey, I'm here!!");
});

app.get("/users", async (req, res) => {
  try {
    const users = await User.find({});

    res.status(200).json({
      users,
    });
  } catch (err) {
    console.log(err);
  }
});

app.post("/user", async (req, res) => {
  try {
    const savedUser = await User.create({ ...req.body });

    res.status(201).json({
      savedUser,
    });
  } catch (err) {
    console.log(err);
  }
});

app.listen(8080, () => {
  console.log("Hello I'm listening on PORT 8080");
});

```

\*\*I am also adding screen shot of my trace logs tab, where you can see that I hit the API ones but getting this messages again and again : \*\*

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/e/2ed89773c7e81ddbb98ffe838d9f30a17e503b9a.png)

**I am also adding my discover tab screenshot here and you can see that I made only one get request and it showing 29 hits there.**

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/4/14c06d507454781a70973ebc1d26e4e781261c3a.png)

I just want to know that why are there are so many hits and Is it necessary to stop them ? And if Yes, so how I can stop them ? Please explain me this, I am searching for this from a long time.

Thanks

---

<div class="post-metadata">

**Author:** ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)\
**Post date:** [August 9, 2021, 6:40pm UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844/2 "2021-08-09T18:40:52Z")

</div>

@Piyush_Mittal What is your query and index for the "Discover" tab screenshot? Some of those "hits" might be things other than "requests to your application". For example the data for the one hit shown in your screenshot is a "metric" data object sent by the APM agent. In addition to sending trace data ("transactions" and "spans"), then APM agent also periodically gathers system and application metrics and sends those. Those are sent every [`metricsInterval`](https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html#metrics-interval) which defaults to 30s.

---

<div class="post-metadata">

**Author:** ![Piyush\_Mittal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/piyush_mittal/32/92656_2.png) [@Piyush\_Mittal](https://discuss.elastic.co/u/Piyush_Mittal)\
**Post date:** [August 9, 2021, 7:33pm UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844/3 "2021-08-09T19:33:41Z")

</div>

@trentm My query is related to that hits:-

1. Is these hits are necessary or Not ?
2. Is these hits increasing the load on our system or server ?
3. Can we stop these hits ?
4. Can we increase these hits timeperiod so these does not make much load on server?
5. Any better solution to this and How I can improve my elastic-apm-node file so, I can  
acheive best results.

Thanks.

---

<div class="post-metadata">

**Author:** ![Piyush\_Mittal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/piyush_mittal/32/92656_2.png) [@Piyush\_Mittal](https://discuss.elastic.co/u/Piyush_Mittal)\
**Post date:** [August 9, 2021, 7:38pm UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844/4 "2021-08-09T19:38:46Z")

</div>

@trentm What is this **failed to find message** meaning in logs came from these metrices ?

Thanks

---

<div class="post-metadata">

**Author:** ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)\
**Post date:** [August 9, 2021, 11:17pm UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844/5 "2021-08-09T23:17:01Z")

</div>

> [@Piyush\_Mittal](#):
>
> - Is these hits are necessary or Not ?
> - Is these hits increasing the load on our system or server ?
> - Can we stop these hits ?
> - Can we increase these hits timeperiod so these does not make much load on server?
> - Any better solution to this and How I can improve my elastic-apm-node file so, I can  
> acheive best results.

1. They are not necessary, no. These collected metrics are a feature of the Elastic APM system. You can read more about how metrics differ from "transactions", "spans", and "errors" that are collected here: [Data Model | APM User Guide [8.11] | Elastic](https://www.elastic.co/guide/en/apm/get-started/current/apm-data-model.html)
2. Yes, there is some load from gathering and sending metrics, but very little. Typically it is on the order of a handful of milliseconds after 30s.
3. Yes, you can stop them by setting `metricsInterval="0s"` in the APM agent config ([Configuration options | APM Node.js Agent Reference [4.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html#metrics-interval)). Note that disabling metrics will mean that some charts in the APM UI in Kibana will not have data to show. Tracing will still be fine.
4. Yes, you can set `metricsInterval` to a larger time span. The resolution of metrics data will be affected, but that may be fine for your case.

> [@Piyush\_Mittal](#):
>
> What is this **failed to find message** meaning in logs came from these metrices ?

From your limited screenshots, I do not know what data that "failed to find message" is showing. That string does not appear in the Node.js APM agent code, nor its dependencies, so I don't know where it is coming from.

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [August 10, 2021, 12:23am UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844/6 "2021-08-10T00:23:53Z")

</div>

"failed to find message" comes from the Logs app in Kibana, when a log entry is missing the `message` field. We would need to see more details of the log entry to further diagnose.

---

<div class="post-metadata">

**Author:** ![Piyush\_Mittal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/piyush_mittal/32/92656_2.png) [@Piyush\_Mittal](https://discuss.elastic.co/u/Piyush_Mittal)\
**Post date:** [August 10, 2021, 12:32pm UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844/7 "2021-08-10T12:32:49Z")

</div>

@axw and @trentm. Ok, I am attaching an screen shot vo detailed view of **failed to find message** logs.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/2/720b4da2ff3efaad1aba241c1d414933b42a4e5b.png)

![image](https://us1.discourse-cdn.com/elastic/original/3X/0/1/0148474e4b2c19a44c6185d33366a7cf445d9e6f.png)

![image](https://us1.discourse-cdn.com/elastic/original/3X/9/1/9198b01368b37757ab5c50863a8f3dc0fe470add.png)

![image](https://us1.discourse-cdn.com/elastic/original/3X/8/8/8883714b194c2b60590d756daec1fa8a8d3400bc.png)

![image](https://us1.discourse-cdn.com/elastic/original/3X/5/3/53b32a8fedfd75f3d3311296495ff894ed6ca34b.png)

**please check above images and please tell what is going over here, I just don't understand anything**

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [August 11, 2021, 1:40am UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844/8 "2021-08-11T01:40:50Z")

</div>

Did you customise the indices for the Logs app? This is a metrics document, in the metrics index. It is not a log record, so that's why the Logs app is having trouble finding the log message.

---

<div class="post-metadata">

**Author:** ![Piyush\_Mittal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/piyush_mittal/32/92656_2.png) [@Piyush\_Mittal](https://discuss.elastic.co/u/Piyush_Mittal)\
**Post date:** [August 11, 2021, 6:20am UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844/9 "2021-08-11T06:20:05Z")

</div>

@axw I think, I don't but I am not sure about it because I am new to it so may be I did it. Can you please tell how I can solve it ??

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [August 11, 2021, 7:21am UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844/10 "2021-08-11T07:21:25Z")

</div>

Take a look at the settings (top right corner) in the Logs app, and then check the "Log indices":

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/9/4943b84c43c9e60406045be335bcde5c0d73ce22.png)

---

<div class="post-metadata">

**Author:** ![Piyush\_Mittal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/piyush_mittal/32/92656_2.png) [@Piyush\_Mittal](https://discuss.elastic.co/u/Piyush_Mittal)\
**Post date:** [August 14, 2021, 7:29pm UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844/11 "2021-08-14T19:29:50Z")

</div>

Hey @axw I am just try to configure this on my ec2 instance, elasticsearch, kibana is configured and now I am looking for apm-server. I installed the package which is mentioned in document but I am not able to find apm-server.yml file. Can u please tell me how I could filnd it ? It's an ubuntu ec2 instance.

Thanks

---

<div class="post-metadata">

**Author:** ![simitt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simitt/32/106406_2.png) [@simitt](https://discuss.elastic.co/u/simitt)\
**Post date:** [August 17, 2021, 10:20am UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844/12 "2021-08-17T10:20:03Z")

</div>

The directory layout depends on how exactly you installed the APM Server, the [docs describing the directory layout](https://www.elastic.co/guide/en/apm/server/current/directory-layout.html) should give you the right pointers where you can find the `apm-server.yml`.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 7, 2021, 6:20am UTC](https://discuss.elastic.co/t/elastic-apm-node-doing-hits-again-and-again/280844/13 "2021-09-07T06:20:56Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
