# Elasticsearch Indexing Rate - API

**URL:** <https://discuss.elastic.co/t/elasticsearch-indexing-rate-api/209312>\
**Category:** Elasticsearch\
**Created:** [November 25, 2019, 1:28pm UTC](https://discuss.elastic.co/t/elasticsearch-indexing-rate-api/209312 "2019-11-25T13:28:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stevesimpson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevesimpson/32/41437_2.png) [@stevesimpson](https://discuss.elastic.co/u/stevesimpson)\
**Post date:** [November 25, 2019, 1:28pm UTC](https://discuss.elastic.co/t/elasticsearch-indexing-rate-api/209312/1 "2019-11-25T13:28:39Z")

</div>

Hi,

I'm trying to calculate the Indexing rate for our cluster using the API. I'm basically trying to replicate the data from the "Monitoring" graphs for our external alerting system. As you can see these are showing an indexing rate of ~3k per second

 ![2019-11-25_13-17](https://us1.discourse-cdn.com/elastic/original/3X/1/5/157e3208b7ee890fd794d2d87aea44e4d02bfe96.png)

A similar question has been asked before so following the advise [here](https://discuss.elastic.co/t/api-to-get-indexing-rate/144159/2) I have ran the following:

GET \_stats?pretty:

```
  "indexing" : {
    "index_total" : 1791502388,
    "index_time_in_millis" : 1339241001,
    "index_current" : 0,
    "index_failed" : 1,
    "delete_total" : 9883899,
    "delete_time_in_millis" : 681911,
    "delete_current" : 0,
    "noop_update_total" : 0,
    "is_throttled" : false,
    "throttle_time_in_millis" : 0
  },

```

Wait 60 seconds then re-run:

```
  "indexing" : {
    "index_total" : 1791564251,
    "index_time_in_millis" : 1339278670,
    "index_current" : 0,
    "index_failed" : 1,
    "delete_total" : 9883899,
    "delete_time_in_millis" : 681911,
    "delete_current" : 0,
    "noop_update_total" : 0,
    "is_throttled" : false,
    "throttle_time_in_millis" : 0
  }

```

Using the calculations given in the above linked answer I get an Indexing rate of **1031/s** ( **1791564251** - **1791502388** )/ **60**

How can I get the same numbers from the graphs above using the API? Is this even possible?

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [November 25, 2019, 2:32pm UTC](https://discuss.elastic.co/t/elasticsearch-indexing-rate-api/209312/2 "2019-11-25T14:32:11Z")

</div>

Hi,

your number seems to match the primary shards metrics of ~ 1100 docs/s pretty well. Quoting from the [index stats API docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html):

> `primaries` are the values for only the primary shards. `total` are the accumulated values for both primary and replica shards.

So I assume that the numbers you got are from the `primaries` but not from `total`.

With regards to the difference you also need to account for the different sampling rate (see `xpack.monitoring.collection.interval` in our [docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/monitoring-settings.html)) which is 10 seconds by default. These two adjustments should bring you pretty close\*) to the numbers you see in the monitoring application.

Daniel

\*) you can't get the exact same values as you'd need to sample at the _exact_ same point in time as x-pack monitoring but that shouldn't be a problem in practice.

---

<div class="post-metadata">

**Author:** ![stevesimpson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stevesimpson/32/41437_2.png) [@stevesimpson](https://discuss.elastic.co/u/stevesimpson)\
**Post date:** [November 25, 2019, 2:37pm UTC](https://discuss.elastic.co/t/elasticsearch-indexing-rate-api/209312/3 "2019-11-25T14:37:21Z")

</div>

Ah! You are indeed correct @danielmitterdorfer I was looking at the primaries rather than the total. Thanks, I feel a bit silly now.

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [November 25, 2019, 2:53pm UTC](https://discuss.elastic.co/t/elasticsearch-indexing-rate-api/209312/4 "2019-11-25T14:53:17Z")

</div>

> [@stevesimpson](#):
>
> I feel a bit silly now.

Don't. Such things can happen so easily. 🙂 I'm glad we could sort it out.

Daniel

---

<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:** [December 23, 2019, 2:53pm UTC](https://discuss.elastic.co/t/elasticsearch-indexing-rate-api/209312/5 "2019-12-23T14:53:27Z")

</div>

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