query-api-key.asciidoc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. [role="xpack"]
  2. [[security-api-query-api-key]]
  3. === Query API key information API
  4. ++++
  5. <titleabbrev>Query API key information</titleabbrev>
  6. ++++
  7. ////
  8. [source,console]
  9. ----
  10. POST /_security/user/king
  11. {
  12. "password" : "security-test-password",
  13. "roles": []
  14. }
  15. POST /_security/user/june
  16. {
  17. "password" : "security-test-password",
  18. "roles": []
  19. }
  20. POST /_security/api_key/grant
  21. {
  22. "grant_type": "password",
  23. "username" : "king",
  24. "password" : "security-test-password",
  25. "api_key" : {
  26. "name": "king-key-no-expire"
  27. }
  28. }
  29. DELETE /_security/api_key
  30. {
  31. "name" : "king-key-no-expire"
  32. }
  33. POST /_security/api_key/grant
  34. {
  35. "grant_type": "password",
  36. "username" : "king",
  37. "password" : "security-test-password",
  38. "api_key" : {
  39. "name": "king-key-10",
  40. "expiration": "10d"
  41. }
  42. }
  43. POST /_security/api_key/grant
  44. {
  45. "grant_type": "password",
  46. "username" : "king",
  47. "password" : "security-test-password",
  48. "api_key" : {
  49. "name": "king-key-100",
  50. "expiration": "100d"
  51. }
  52. }
  53. POST /_security/api_key/grant
  54. {
  55. "grant_type": "password",
  56. "username" : "june",
  57. "password" : "security-test-password",
  58. "api_key" : {
  59. "name": "june-key-no-expire"
  60. }
  61. }
  62. POST /_security/api_key/grant
  63. {
  64. "grant_type": "password",
  65. "username" : "june",
  66. "password" : "security-test-password",
  67. "api_key" : {
  68. "name": "june-key-10",
  69. "expiration": "10d"
  70. }
  71. }
  72. POST /_security/api_key/grant
  73. {
  74. "grant_type": "password",
  75. "username" : "june",
  76. "password" : "security-test-password",
  77. "api_key" : {
  78. "name": "june-key-100",
  79. "expiration": "100d"
  80. }
  81. }
  82. DELETE /_security/api_key
  83. {
  84. "name" : "june-key-100"
  85. }
  86. ----
  87. // TESTSETUP
  88. [source,console]
  89. --------------------------------------------------
  90. DELETE /_security/user/king
  91. DELETE /_security/user/june
  92. DELETE /_security/api_key
  93. {
  94. "name" : "king-key-no-expire"
  95. }
  96. DELETE /_security/api_key
  97. {
  98. "name" : "king-key-10"
  99. }
  100. DELETE /_security/api_key
  101. {
  102. "name" : "king-key-100"
  103. }
  104. DELETE /_security/api_key
  105. {
  106. "name" : "june-key-no-expire"
  107. }
  108. DELETE /_security/api_key
  109. {
  110. "name" : "june-key-10"
  111. }
  112. --------------------------------------------------
  113. // TEARDOWN
  114. ////
  115. Retrieves information for API keys with <<query-dsl,Query DSL>>
  116. in a <<paginate-search-results,paginated>> fashion.
  117. [[security-api-query-api-key-request]]
  118. ==== {api-request-title}
  119. `GET /_security/_query/api_key`
  120. `POST /_security/_query/api_key`
  121. [[security-api-query-api-key-prereqs]]
  122. ==== {api-prereq-title}
  123. * To use this API, you must have at least the `manage_own_api_key` or the `read_security`
  124. cluster privileges.
  125. * If you have only the `manage_own_api_key` privilege, this API returns only
  126. the API keys that you own. If you have the `read_security`, `manage_api_key` or greater
  127. privileges (including `manage_security`), this API returns all API keys
  128. regardless of ownership.
  129. [[security-api-query-api-key-desc]]
  130. ==== {api-description-title}
  131. Use this API to retrieve the API keys created with the
  132. <<security-api-create-api-key,create API key API>> in a paginated manner.
  133. You can optionally filter the results with a query.
  134. [[security-api-query-api-key-query-params]]
  135. ==== {api-path-parms-title}
  136. `with_limited_by`::
  137. (Optional, Boolean) A boolean flag to return the snapshot of the owner user's role descriptors
  138. associated with the API key. An API key's actual permission is the intersection of
  139. its <<api-key-role-descriptors,assigned role descriptors>> and the owner user's role descriptors
  140. (effectively limited by it). An API key cannot retrieve any API key's limited-by role descriptors
  141. (including itself) unless it has `manage_api_key` or higher privileges.
  142. `with_profile_uid`::
  143. (Optional, boolean) Determines whether to also retrieve the <<user-profile,user profile>> `uid`, for the API key owner user.
  144. If it exists, the profile uid is returned under the `profile_uid` response field for each API key.
  145. Defaults to `false`.
  146. [[security-api-query-api-key-request-body]]
  147. ==== {api-request-body-title}
  148. You can specify the following parameters in the request body:
  149. `query`::
  150. (Optional, object) A <<query-dsl,query>> to filter which API keys to return.
  151. If the query parameter is missing, it is equivalent to a `match_all` query.
  152. The query supports a subset of query types, including
  153. <<query-dsl-match-all-query,`match_all`>>, <<query-dsl-bool-query,`bool`>>,
  154. <<query-dsl-term-query,`term`>>, <<query-dsl-terms-query,`terms`>>,
  155. <<query-dsl-match-query,`match`>>, <<query-dsl-ids-query,`ids`>>,
  156. <<query-dsl-prefix-query,`prefix`>>, <<query-dsl-wildcard-query,`wildcard`>>,
  157. <<query-dsl-exists-query,`exists`>>, <<query-dsl-range-query,`range`>>,
  158. and <<query-dsl-simple-query-string-query,`simple query string`>>
  159. +
  160. You can query the following public values associated with an API key.
  161. +
  162. NOTE: The queryable string values associated with API keys are internally mapped as <<keyword,`keywords`>>.
  163. Consequently, if no <<analysis-analyzers,`analyzer`>> parameter is specified for a
  164. <<query-dsl-match-query,`match`>> query, then the provided match query string is interpreted as
  165. a single keyword value. Such a <<query-dsl-match-query,`match`>> query is hence equivalent to a
  166. <<query-dsl-term-query,`term`>> query.
  167. +
  168. .Valid values for `query`
  169. [%collapsible%open]
  170. ====
  171. `id`::
  172. ID of the API key. Note `id` must be queried with the <<query-dsl-ids-query,`ids`>> query.
  173. `type`::
  174. API keys can be of type `rest`, if created via the <<security-api-create-api-key, Create API key>> or
  175. the <<security-api-grant-api-key, Grant API key>> APIs, or of type `cross_cluster` if created via
  176. the <<security-api-create-cross-cluster-api-key, Create Cross-Cluster API key>> API.
  177. `name`::
  178. Name of the API key.
  179. `creation`::
  180. Creation time of the API key in milliseconds.
  181. `expiration`::
  182. Expiration time of the API key in milliseconds. This is `null` if the key was not configured to expire.
  183. `invalidated`::
  184. Indicates whether the API key is invalidated. If `true`, the key is invalidated.
  185. Defaults to `false`.
  186. `invalidation`::
  187. Invalidation time of the API key in milliseconds. This field is only set for invalidated API keys.
  188. `username`::
  189. Username of the API key owner.
  190. `realm`::
  191. Realm name of the API key owner.
  192. `metadata`::
  193. Metadata field associated with the API key, such as `metadata.my_field`.
  194. Metadata is internally indexed as a <<flattened,flattened>> field type.
  195. This means that all fields act like `keyword` fields when querying and sorting.
  196. It's not possible to refer to a subset of metadata fields using wildcard
  197. patterns, e.g. `metadata.field*`, even for query types that support field
  198. name patterns. Lastly, all the metadata fields can be searched together when
  199. simply mentioning `metadata` (not followed by any dot and sub-field name).
  200. NOTE: You cannot query the role descriptors of an API key.
  201. ====
  202. `aggs`::
  203. (Optional, object) Any <<search-aggregations,aggregations>> to run over the corpus of returned API keys.
  204. Aggregations and queries work together. Aggregations are computed only on the API keys that match the query.
  205. This supports only a subset of aggregation types, namely: <<search-aggregations-bucket-terms-aggregation,terms>>,
  206. <<search-aggregations-bucket-range-aggregation,range>>, <<search-aggregations-bucket-daterange-aggregation,date range>>,
  207. <<search-aggregations-bucket-missing-aggregation,missing>>, <<search-aggregations-metrics-cardinality-aggregation,cardinality>>,
  208. <<search-aggregations-metrics-valuecount-aggregation,value count>>, <<search-aggregations-bucket-composite-aggregation,composite>>,
  209. <<search-aggregations-bucket-filter-aggregation,filter>>, and <<search-aggregations-bucket-filters-aggregation,filters>>.
  210. Additionally, aggregations only run over the same subset of fields that `query` works with.
  211. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=from]
  212. +
  213. By default, you cannot page through more than 10,000 hits using the `from` and
  214. `size` parameters. To page through more hits, use the
  215. <<search-after,`search_after`>> parameter.
  216. `size`::
  217. (Optional, integer) The number of hits to return. Must not be negative and defaults to `10`.
  218. The `size` parameter can be set to `0`, in which case no API key matches are returned,
  219. only the aggregation results.
  220. +
  221. By default, you cannot page through more than 10,000 hits using the `from` and
  222. `size` parameters. To page through more hits, use the
  223. <<search-after,`search_after`>> parameter.
  224. `sort`::
  225. (Optional, object) <<sort-search-results,Sort definition>>. Other than `id`,
  226. all public fields of an API key are eligible for sorting. In addition, sort can
  227. also be applied to the `_doc` field to sort by index order.
  228. `search_after`::
  229. (Optional, array) <<search-after,Search after>> definition.
  230. [[security-api-query-api-key-response-body]]
  231. ==== {api-response-body-title}
  232. This API returns the following top level fields:
  233. `total`::
  234. The total number of API keys found.
  235. `count`::
  236. The number of API keys returned in the response.
  237. `api_keys`::
  238. A list of API key information.
  239. [[security-api-query-api-key-example]]
  240. ==== {api-examples-title}
  241. The following request lists all API keys, assuming you have the
  242. `manage_api_key` privilege:
  243. [source,console]
  244. ----
  245. GET /_security/_query/api_key
  246. ----
  247. A successful call returns a JSON structure that contains the information
  248. retrieved from one or more API keys:
  249. [source,js]
  250. ----
  251. {
  252. "total": 3,
  253. "count": 3,
  254. "api_keys": [ <1>
  255. {
  256. "id": "nkvrGXsB8w290t56q3Rg",
  257. "name": "my-api-key-1",
  258. "creation": 1628227480421,
  259. "expiration": 1629091480421,
  260. "invalidated": false,
  261. "username": "elastic",
  262. "realm": "reserved",
  263. "realm_type": "reserved",
  264. "metadata": {
  265. "letter": "a"
  266. },
  267. "role_descriptors": { <2>
  268. "role-a": {
  269. "cluster": [
  270. "monitor"
  271. ],
  272. "indices": [
  273. {
  274. "names": [
  275. "index-a"
  276. ],
  277. "privileges": [
  278. "read"
  279. ],
  280. "allow_restricted_indices": false
  281. }
  282. ],
  283. "applications": [ ],
  284. "run_as": [ ],
  285. "metadata": { },
  286. "transient_metadata": {
  287. "enabled": true
  288. }
  289. }
  290. }
  291. },
  292. {
  293. "id": "oEvrGXsB8w290t5683TI",
  294. "name": "my-api-key-2",
  295. "creation": 1628227498953,
  296. "expiration": 1628313898953,
  297. "invalidated": false,
  298. "username": "elastic",
  299. "realm": "reserved",
  300. "metadata": {
  301. "letter": "b"
  302. },
  303. "role_descriptors": { } <3>
  304. }
  305. ]
  306. }
  307. ----
  308. // NOTCONSOLE
  309. <1> The list of API keys that were retrieved for this request
  310. <2> The role descriptors that are assigned to this API key when it was <<api-key-role-descriptors,created>>
  311. or last <<security-api-update-api-key-api-key-role-descriptors,updated>>. Note the API key's
  312. effective permissions are an intersection of its assigned privileges and the point-in-time snapshot of
  313. the owner user's permissions.
  314. <3> An empty role descriptors means the API key inherits the owner user's permissions.
  315. If you create an API key with the following details:
  316. [source,console]
  317. ----
  318. POST /_security/api_key
  319. {
  320. "name": "application-key-1",
  321. "metadata": { "application": "my-application"}
  322. }
  323. ----
  324. A successful call returns a JSON structure that provides
  325. API key information. For example:
  326. [source,console-result]
  327. ----
  328. {
  329. "id": "VuaCfGcBCdbkQm-e5aOx",
  330. "name": "application-key-1",
  331. "api_key": "ui2lp2axTNmsyakw9tvNnw",
  332. "encoded": "VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw=="
  333. }
  334. ----
  335. // TESTRESPONSE[s/VuaCfGcBCdbkQm-e5aOx/$body.id/]
  336. // TESTRESPONSE[s/ui2lp2axTNmsyakw9tvNnw/$body.api_key/]
  337. // TESTRESPONSE[s/VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw==/$body.encoded/]
  338. Use the information from the response to retrieve the API key by ID:
  339. [source,console]
  340. ----
  341. GET /_security/_query/api_key?with_limited_by=true
  342. {
  343. "query": {
  344. "ids": {
  345. "values": [
  346. "VuaCfGcBCdbkQm-e5aOx"
  347. ]
  348. }
  349. }
  350. }
  351. ----
  352. // TEST[s/VuaCfGcBCdbkQm-e5aOx/$body.id/]
  353. // TEST[continued]
  354. A successful call returns a JSON structure for API key information including its limited-by role descriptors:
  355. [source,js]
  356. --------------------------------------------------
  357. {
  358. "api_keys": [
  359. {
  360. "id": "VuaCfGcBCdbkQm-e5aOx",
  361. "name": "application-key-1",
  362. "creation": 1548550550158,
  363. "expiration": 1548551550158,
  364. "invalidated": false,
  365. "username": "myuser",
  366. "realm": "native1",
  367. "realm_type": "native",
  368. "metadata": {
  369. "application": "my-application"
  370. },
  371. "role_descriptors": { },
  372. "limited_by": [ <1>
  373. {
  374. "role-power-user": {
  375. "cluster": [
  376. "monitor"
  377. ],
  378. "indices": [
  379. {
  380. "names": [
  381. "*"
  382. ],
  383. "privileges": [
  384. "read"
  385. ],
  386. "allow_restricted_indices": false
  387. }
  388. ],
  389. "applications": [ ],
  390. "run_as": [ ],
  391. "metadata": { },
  392. "transient_metadata": {
  393. "enabled": true
  394. }
  395. }
  396. }
  397. ]
  398. }
  399. ]
  400. }
  401. --------------------------------------------------
  402. // NOTCONSOLE
  403. <1> The owner user's permissions associated with the API key.
  404. It is a point-in-time snapshot captured at <<security-api-create-api-key,creation>> and
  405. subsequent <<security-api-update-api-key,updates>>. An API key's
  406. effective permissions are an intersection of its assigned privileges and
  407. the owner user's permissions.
  408. You can also retrieve the API key by name:
  409. [source,console]
  410. ----
  411. GET /_security/_query/api_key
  412. {
  413. "query": {
  414. "term": {
  415. "name": {
  416. "value": "application-key-1"
  417. }
  418. }
  419. }
  420. }
  421. ----
  422. // TEST[continued]
  423. Use a `bool` query to issue complex logical conditions and use
  424. `from`, `size`, `sort` to help paginate the result:
  425. [source,js]
  426. ----
  427. GET /_security/_query/api_key
  428. {
  429. "query": {
  430. "bool": {
  431. "must": [
  432. {
  433. "prefix": {
  434. "name": "app1-key-" <1>
  435. }
  436. },
  437. {
  438. "term": {
  439. "invalidated": "false" <2>
  440. }
  441. }
  442. ],
  443. "must_not": [
  444. {
  445. "term": {
  446. "name": "app1-key-01" <3>
  447. }
  448. }
  449. ],
  450. "filter": [
  451. {
  452. "wildcard": {
  453. "username": "org-*-user" <4>
  454. }
  455. },
  456. {
  457. "term": {
  458. "metadata.environment": "production" <5>
  459. }
  460. }
  461. ]
  462. }
  463. },
  464. "from": 20, <6>
  465. "size": 10, <7>
  466. "sort": [ <8>
  467. { "creation": { "order": "desc", "format": "date_time" } },
  468. "name"
  469. ]
  470. }
  471. ----
  472. // NOTCONSOLE
  473. <1> The API key name must begin with `app1-key-`
  474. <2> The API key must still be valid
  475. <3> The API key name must not be `app1-key-01`
  476. <4> The API key must be owned by a username of the <<query-dsl-wildcard-query,wildcard>> pattern `org-*-user`
  477. <5> The API key must have the metadata field `environment` that has the value of `production`
  478. <6> The offset to begin the search result is the 20th (zero-based index) API key
  479. <7> The page size of the response is 10 API keys
  480. <8> The result is first sorted by `creation` date in descending order, then by name in ascending order
  481. The response contains a list of matched API keys along with their sort values:
  482. [source,js]
  483. ----
  484. {
  485. "total": 100,
  486. "count": 10,
  487. "api_keys": [
  488. {
  489. "id": "CLXgVnsBOGkf8IyjcXU7",
  490. "name": "app1-key-79",
  491. "creation": 1629250154811,
  492. "invalidated": false,
  493. "username": "org-admin-user",
  494. "realm": "native1",
  495. "metadata": {
  496. "environment": "production"
  497. },
  498. "role_descriptors": { },
  499. "_sort": [
  500. "2021-08-18T01:29:14.811Z", <1>
  501. "app1-key-79" <2>
  502. ]
  503. },
  504. {
  505. "id": "BrXgVnsBOGkf8IyjbXVB",
  506. "name": "app1-key-78",
  507. "creation": 1629250153794,
  508. "invalidated": false,
  509. "username": "org-admin-user",
  510. "realm": "native1",
  511. "metadata": {
  512. "environment": "production"
  513. },
  514. "role_descriptors": { },
  515. "_sort": [
  516. "2021-08-18T01:29:13.794Z",
  517. "app1-key-78"
  518. ]
  519. },
  520. ...
  521. ]
  522. }
  523. ----
  524. // NOTCONSOLE
  525. <1> The first sort value is creation time, which is displayed in `date_time` <<mapping-date-format,format>> as defined in the request
  526. <2> The second sort value is the API key name
  527. [[security-api-query-api-key-with-aggs-example]]
  528. ==== Aggregations Example
  529. For example, given 2 users "june" and "king", each owning 3 API keys:
  530. * one that never expires (invalidated for user "king")
  531. * one that expires in 10 days
  532. * and one that expires in 100 day (invalidated for user "june")
  533. the following request returns the names of valid (not expired and not invalidated) API keys
  534. that expire soon (in 30 days time), grouped by owner username.
  535. ===== Request
  536. [source,console]
  537. ----
  538. POST /_security/_query/api_key
  539. {
  540. "size": 0,
  541. "query": {
  542. "bool": {
  543. "must": {
  544. "term": {
  545. "invalidated": false <1>
  546. }
  547. },
  548. "should": [ <2>
  549. {
  550. "range": { "expiration": { "gte": "now" } }
  551. },
  552. {
  553. "bool": { "must_not": { "exists": { "field": "expiration" } } }
  554. }
  555. ],
  556. "minimum_should_match": 1
  557. }
  558. },
  559. "aggs": {
  560. "keys_by_username": {
  561. "composite": {
  562. "sources": [ { "usernames": { "terms": { "field": "username" } } } ] <3>
  563. },
  564. "aggs": {
  565. "expires_soon": {
  566. "filter": {
  567. "range": { "expiration": { "lte": "now+30d/d" } } <4>
  568. },
  569. "aggs": {
  570. "key_names": { "terms": { "field": "name" } }
  571. }
  572. }
  573. }
  574. }
  575. }
  576. }
  577. ----
  578. <1> Matching API keys must not be invalidated
  579. <2> Matching API keys must be either not expired or not have an expiration date
  580. <3> Aggregate all matching keys (i.e. all valid keys) by their owner username
  581. <4> Further aggregate the per-username valid keys into a soon-to-expire bucket
  582. ===== Response
  583. [source,console-result]
  584. ----
  585. {
  586. "total" : 4, <1>
  587. "count" : 0,
  588. "api_keys" : [ ],
  589. "aggregations" : {
  590. "keys_by_username" : {
  591. "after_key" : {
  592. "usernames" : "king"
  593. },
  594. "buckets" : [
  595. {
  596. "key" : {
  597. "usernames" : "june"
  598. },
  599. "doc_count" : 2, <2>
  600. "expires_soon" : {
  601. "doc_count" : 1,
  602. "key_names" : {
  603. "doc_count_error_upper_bound" : 0,
  604. "sum_other_doc_count" : 0,
  605. "buckets" : [
  606. {
  607. "key" : "june-key-10",
  608. "doc_count" : 1
  609. }
  610. ]
  611. }
  612. }
  613. },
  614. {
  615. "key" : {
  616. "usernames" : "king"
  617. },
  618. "doc_count" : 2,
  619. "expires_soon" : {
  620. "doc_count" : 1, <3>
  621. "key_names" : {
  622. "doc_count_error_upper_bound" : 0,
  623. "sum_other_doc_count" : 0,
  624. "buckets" : [ <4>
  625. {
  626. "key" : "king-key-10",
  627. "doc_count" : 1
  628. }
  629. ]
  630. }
  631. }
  632. }
  633. ]
  634. }
  635. }
  636. }
  637. ----
  638. <1> Total number of valid API keys (2 for each user)
  639. <2> Number of valid API keys for user "june"
  640. <3> Number of valid API keys expiring soon for user "king"
  641. <4> The names of soon-to-expire API keys for user "king"
  642. To retrieve the invalidated (but not yet deleted) API keys,
  643. grouped by owner username and API key name, issue the following request:
  644. ===== Request
  645. [source,console]
  646. ----
  647. POST /_security/_query/api_key
  648. {
  649. "size": 0,
  650. "query": {
  651. "bool": {
  652. "filter": {
  653. "term": {
  654. "invalidated": true
  655. }
  656. }
  657. }
  658. },
  659. "aggs": {
  660. "invalidated_keys": {
  661. "composite": {
  662. "sources": [
  663. { "username": { "terms": { "field": "username" } } },
  664. { "key_name": { "terms": { "field": "name" } } }
  665. ]
  666. }
  667. }
  668. }
  669. }
  670. ----
  671. ===== Response
  672. [source,console-result]
  673. ----
  674. {
  675. "total" : 2,
  676. "count" : 0,
  677. "api_keys" : [ ],
  678. "aggregations" : {
  679. "invalidated_keys" : {
  680. "after_key" : {
  681. "username" : "king",
  682. "key_name" : "king-key-no-expire"
  683. },
  684. "buckets" : [
  685. {
  686. "key" : {
  687. "username" : "june",
  688. "key_name" : "june-key-100"
  689. },
  690. "doc_count" : 1
  691. },
  692. {
  693. "key" : {
  694. "username" : "king",
  695. "key_name" : "king-key-no-expire"
  696. },
  697. "doc_count" : 1
  698. }
  699. ]
  700. }
  701. }
  702. }
  703. ----