# Which API query to use to count logs

**URL:** <https://community.graylog.org/t/which-api-query-to-use-to-count-logs/24495>\
**Category:** JSON Templates\
**Tags:** jsonfblx, curl\
**Created:** [June 27, 2022, 12:54pm UTC](https://community.graylog.org/t/which-api-query-to-use-to-count-logs/24495 "2022-06-27T12:54:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![UserIT529](https://avatars.discourse-cdn.com/v4/letter/u/dbc845/32.png) [@UserIT529](https://community.graylog.org/u/UserIT529)\
**Post date:** [June 27, 2022, 12:54pm UTC](https://community.graylog.org/t/which-api-query-to-use-to-count-logs/24495/1 "2022-06-27T12:54:09Z")

</div>

```auto
Hello, everyone,
I haven't been using Graylog for longPreformatted text. Now I have it set up and can monitor four servers. I would now like to use the API to query whether a server has written log files in the last few hours. Not more.
I'm currently trying the "views/search" query. I have already shortened the code to the bare essentials. Now I have a few questions. Can I even use the query for this? How do I enter query_string? for example: "agent_name:abcd\efgh\-u05".

Which IDs do I have to enter at the positions?

I would be very happy about helpful answers.

This is my code:
{
  "queries" : [
  {
      "query" : 
      {
        "type" : "elasticsearch",
        "query_string" : "*"
      },
      "id" : "4d640ed0f61211ecb1a7005056870c0e",
      "timerange" : 
      {
        "type": "relative",
        "range": 600
      }
  }
  ],
  "id" : "5ff438549150ddc6b4ce5319"
}
```

---

<div class="post-metadata">

**Author:** ![gsmith](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/gsmith/32/1222_2.png) [@gsmith](https://community.graylog.org/u/gsmith)\
**Post date:** [June 27, 2022, 10:06pm UTC](https://community.graylog.org/t/which-api-query-to-use-to-count-logs/24495/2 "2022-06-27T22:06:24Z")

</div>

Hello && welcome @UserIT529

> [@UserIT529](#):
>
> `Which IDs do I have to enter at the positions?`

Not sure exactly what you doing or version you have but try using Graylogs API Dashboard. It located  
under _System/Nodes_

 ![image](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/2X/b/b9bcab9c70eea9638b7703114e845437a87a82d4.png)

From there you can get you ID’s, etc…

---

<div class="post-metadata">

**Author:** ![UserIT529](https://avatars.discourse-cdn.com/v4/letter/u/dbc845/32.png) [@UserIT529](https://community.graylog.org/u/UserIT529)\
**Post date:** [June 28, 2022, 5:51am UTC](https://community.graylog.org/t/which-api-query-to-use-to-count-logs/24495/3 "2022-06-28T05:51:54Z")

</div>

Thank you, for your answer!  
But on your screenshot I can´t see any ID´s… I mean the ID´s in the Code. Where can I find them?

---

<div class="post-metadata">

**Author:** ![gsmith](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/gsmith/32/1222_2.png) [@gsmith](https://community.graylog.org/u/gsmith)\
**Post date:** [June 28, 2022, 9:15pm UTC](https://community.graylog.org/t/which-api-query-to-use-to-count-logs/24495/4 "2022-06-28T21:15:55Z")

</div>

Hello,

You may want to look at this document.

- [Graylog REST API - Configuring Graylog](https://docs.graylog.org/docs/rest-api)
