---
type: api
title: Get security stats
description: Gather security usage statistics from all node(s) within the cluster.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-security-get-stats
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-security-get-stats
products:
  - Elasticsearch
---

# Get security stats

Availability: Generally available since 9.2

## Paths

- `GET` `/_security/stats`

## Description

Gather security usage statistics from all node(s) within the cluster.

## Required authorization

- Cluster privileges: `monitor`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/token-based-authentication-services)

## Response

`application/json`

- `nodes` (map string to object)
  A map of node IDs to security statistics for that node.
  Map values (object)
  - `roles` (object)
    Role statistics.
    - `dls` (object)
      Document-level security (DLS) statistics.
      - `bit_set_cache` (object)
        - `count` (number)
          Number of entries in the cache.
        - `memory` (number | string)
          Human-readable amount of memory taken up by the cache.
        - `memory_in_bytes` (number)
          Memory taken up by the cache in bytes.
        - `hits` (number)
          Total number of cache hits.
        - `misses` (number)
          Total number of cache misses.
        - `evictions` (number)
          Total number of cache evictions.
        - `hits_time_in_millis` (number)
          Total combined time spent in cache for hits in milliseconds.
        - `misses_time_in_millis` (number)
          Total combined time spent in cache for misses in milliseconds.
## Code examples

#### Console

```console
GET /_security/stats
```

#### curl

```curl
curl -X GET "${ELASTICSEARCH_URL}/_security/stats" \
  -H "Authorization: ApiKey ${API_KEY}"
```

## Response examples

#### Security stats example1

A successful response from `GET /_security/stats`.

```json
{
  "nodes": {
    "CLeCBfYETO2mQ1R2Il5-SA": {
      "roles": {
        "dls": {
          "bit_set_cache": {
            "count": 1,
            "memory": "16b",
            "memory_in_bytes": 16,
            "hits": 212,
            "misses": 1,
            "evictions": 0,
            "hits_time_in_millis": 5,
            "misses_time_in_millis": 0
          }
        }
      }
    }
  }
}
```

