/usr/share/doc/python-elasticsearch-curator-doc/html/_sources/examples.txt is in python-elasticsearch-curator-doc 4.2.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | .. _examples:
Examples
========
Each of these examples presupposes that the requisite modules have been imported
and an instance of the Elasticsearch client object has been created:
::
import elasticsearch
import curator
client = elasticsearch.Elasticsearch()
Filter indices by prefix
++++++++++++++++++++++++
::
ilo = curator.IndexList(client)
ilo.filter_by_regex(kind='prefix', value='logstash-')
The contents of `ilo.indices` would then only be indices matching the `prefix`.
Filter indices by suffix
++++++++++++++++++++++++
::
ilo = curator.IndexList(client)
ilo.filter_by_regex(kind='suffix', value='-prod')
The contents of `ilo.indices` would then only be indices matching the `suffix`.
Filter indices by age (name)
++++++++++++++++++++++++++++
This example will match indices with the following criteria:
* Have a date string of ``%Y.%m.%d``
* Use `days` as the unit of time measurement
* Filter indices `older` than 5 `days`
::
ilo = curator.IndexList(client)
ilo.filter_by_age(source='name', direction='older', timestring='%Y.%m.%d',
unit='days', unit_count=5
)
The contents of `ilo.indices` would then only be indices matching these
criteria.
Filter indices by age (creation_date)
+++++++++++++++++++++++++++++++++++++
This example will match indices with the following criteria:
* Use `months` as the unit of time measurement
* Filter indices where the index creation date is `older` than 2 `months` from
this moment.
::
ilo = curator.IndexList(client)
ilo.filter_by_age(source='creation_date', direction='older',
unit='months', unit_count=2
)
The contents of `ilo.indices` would then only be indices matching these
criteria.
Filter indices by age (field_stats)
+++++++++++++++++++++++++++++++++++
This example will match indices with the following criteria:
* Use `days` as the unit of time measurement
* Filter indices where the `timestamp` field's `min_value` is a date `older`
than 3 `weeks` from this moment.
::
ilo = curator.IndexList(client)
ilo.filter_by_age(source='field_stats', direction='older',
unit='weeks', unit_count=3, field='timestamp', stats_result='min_value'
)
The contents of `ilo.indices` would then only be indices matching these
criteria.
|