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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823
|
[[examples]]
= Examples
[partintro]
--
These examples should help illustrate how to build your own <<actions,actions>>.
You can use <<envvars,environment variables>> in your configuration files.
* <<ex_alias,alias>>
* <<ex_allocation,allocation>>
* <<ex_close,close>>
* <<ex_cluster_routing,cluster_routing>>
* <<ex_create_index,create_index>>
* <<ex_delete_indices,delete_indices>>
* <<ex_delete_snapshots,delete_snapshots>>
* <<ex_forcemerge,forcemerge>>
* <<ex_open,open>>
* <<ex_reindex,reindex>>
* <<ex_replicas,replicas>>
* <<ex_restore,restore>>
* <<ex_rollover,rollover>>
* <<ex_shrink,shrink>>
* <<ex_snapshot,snapshot>>
--
[[ex_alias]]
== alias
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: alias
description: >-
Alias indices from last week, with a prefix of logstash- to 'last_week',
remove indices from the previous week.
options:
name: last_week
warn_if_no_indices: False
disable_action: True
add:
filters:
- filtertype: pattern
kind: prefix
value: logstash-
exclude:
- filtertype: period
period_type: relative
source: name
range_from: -1
range_to: -1
timestring: '%Y.%m.%d'
unit: weeks
week_starts_on: sunday
remove:
filters:
- filtertype: pattern
kind: prefix
value: logstash-
- filtertype: period
period_type: relative
source: name
range_from: -2
range_to: -2
timestring: '%Y.%m.%d'
unit: weeks
week_starts_on: sunday
-------------
[[ex_allocation]]
== allocation
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: allocation
description: >-
Apply shard allocation routing to 'require' 'tag=cold' for hot/cold node
setup for logstash- indices older than 3 days, based on index_creation
date
options:
key: tag
value: cold
allocation_type: require
disable_action: True
filters:
- filtertype: pattern
kind: prefix
value: logstash-
- filtertype: age
source: creation_date
direction: older
unit: days
unit_count: 3
-------------
[[ex_close]]
== close
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: close
description: >-
Close indices older than 30 days (based on index name), for logstash-
prefixed indices.
options:
skip_flush: False
delete_aliases: False
ignore_sync_failures: True
disable_action: True
filters:
- filtertype: pattern
kind: prefix
value: logstash-
- filtertype: age
source: name
direction: older
timestring: '%Y.%m.%d'
unit: days
unit_count: 30
-------------
[[ex_cluster_routing]]
== cluster_routing
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
#
# This action example has a blank spot at action ID 2. This is to show that
# Curator can disable allocation before one or more actions, and then re-enable
# it afterward.
actions:
1:
action: cluster_routing
description: >-
Disable shard routing for the entire cluster.
options:
routing_type: allocation
value: none
setting: enable
wait_for_completion: True
disable_action: True
2:
action: (any other action details go here)
...
3:
action: cluster_routing
description: >-
Re-enable shard routing for the entire cluster.
options:
routing_type: allocation
value: all
setting: enable
wait_for_completion: True
disable_action: True
-------------
[[ex_create_index]]
== create_index
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: create_index
description: Create the index as named, with the specified extra settings.
options:
name: myindex
extra_settings:
settings:
number_of_shards: 2
number_of_replicas: 1
disable_action: True
-------------
[[ex_delete_indices]]
== delete_indices
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: delete_indices
description: >-
Delete indices older than 45 days (based on index name), for logstash-
prefixed indices. Ignore the error if the filter does not result in an
actionable list of indices (ignore_empty_list) and exit cleanly.
options:
ignore_empty_list: True
disable_action: True
filters:
- filtertype: pattern
kind: prefix
value: logstash-
- filtertype: age
source: name
direction: older
timestring: '%Y.%m.%d'
unit: days
unit_count: 45
-------------
[[ex_delete_snapshots]]
== delete_snapshots
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: delete_snapshots
description: >-
Delete snapshots from the selected repository older than 45 days
(based on creation_date), for 'curator-' prefixed snapshots.
options:
repository:
disable_action: True
filters:
- filtertype: pattern
kind: prefix
value: curator-
exclude:
- filtertype: age
source: creation_date
direction: older
unit: days
unit_count: 45
-------------
[[ex_forcemerge]]
== forcemerge
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: forcemerge
description: >-
forceMerge logstash- prefixed indices older than 2 days (based on index
creation_date) to 2 segments per shard. Delay 120 seconds between each
forceMerge operation to allow the cluster to quiesce. Skip indices that
have already been forcemerged to the minimum number of segments to avoid
reprocessing.
options:
max_num_segments: 2
delay: 120
timeout_override:
continue_if_exception: False
disable_action: True
filters:
- filtertype: pattern
kind: prefix
value: logstash-
exclude:
- filtertype: age
source: creation_date
direction: older
unit: days
unit_count: 2
exclude:
- filtertype: forcemerged
max_num_segments: 2
exclude:
-------------
[[ex_index_settings]]
== index_settings
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: index_settings
description: >-
Set Logstash indices older than 10 days to be read only (block writes)
options:
disable_action: True
index_settings:
index:
blocks:
write: True
ignore_unavailable: False
preserve_existing: False
filters:
- filtertype: pattern
kind: prefix
value: logstash-
exclude:
- filtertype: age
source: name
direction: older
timestring: '%Y.%m.%d'
unit: days
unit_count: 10
-------------
[[ex_open]]
== open
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: open
description: >-
Open indices older than 30 days but younger than 60 days (based on index
name), for logstash- prefixed indices.
options:
disable_action: True
filters:
- filtertype: pattern
kind: prefix
value: logstash-
exclude:
- filtertype: age
source: name
direction: older
timestring: '%Y.%m.%d'
unit: days
unit_count: 30
- filtertype: age
source: name
direction: younger
timestring: '%Y.%m.%d'
unit: days
unit_count: 60
-------------
[[ex_reindex]]
== reindex
=== Manually selected reindex of a single index
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
description: "Reindex index1 into index2"
action: reindex
options:
disable_action: True
wait_interval: 9
max_wait: -1
request_body:
source:
index: index1
dest:
index: index2
filters:
- filtertype: none
-------------
=== Manually selected reindex of a multiple indices
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
description: "Reindex index1,index2,index3 into new_index"
action: reindex
options:
disable_action: True
wait_interval: 9
max_wait: -1
request_body:
source:
index: ['index1', 'index2', 'index3']
dest:
index: new_index
filters:
- filtertype: none
-------------
=== Filter-Selected Indices
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
description: >-
'Reindex all daily logstash indices from March 2017 into logstash-2017.03'
action: reindex
options:
disable_action: True
wait_interval: 9
max_wait: -1
request_body:
source:
index: REINDEX_SELECTION
dest:
index: logstash-2017.03
filters:
- filtertype: pattern
kind: prefix
value: logstash-2017.03.
-------------
=== Reindex From Remote
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
description: >-
'Reindex all daily logstash indices from March 2017 into logstash-2017.03'
action: reindex
options:
disable_action: True
wait_interval: 9
max_wait: -1
request_body:
source:
remote:
host: http://otherhost:9200
username: myuser
password: mypass
index: index1
dest:
index: index1
filters:
- filtertype: none
-------------
=== Reindex From Remote With Filter-Selected Indices
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
description: >-
Reindex all remote daily logstash indices from March 2017 into local index
logstash-2017.03
action: reindex
options:
disable_action: True
wait_interval: 9
max_wait: -1
request_body:
source:
remote:
host: http://otherhost:9200
username: myuser
password: mypass
index: REINDEX_SELECTION
dest:
index: logstash-2017.03
remote_filters:
- filtertype: pattern
kind: prefix
value: logstash-2017.03.
filters:
- filtertype: none
-------------
=== Manually selected reindex of a single index with query
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
description: "Reindex index1 into index2"
action: reindex
options:
disable_action: True
wait_interval: 9
max_wait: -1
request_body:
source:
query:
range:
timestamp:
gte: "now-1h"
index: index1
dest:
index: index2
filters:
- filtertype: none
-------------
[[ex_replicas]]
== replicas
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: replicas
description: >-
Reduce the replica count to 0 for logstash- prefixed indices older than
10 days (based on index creation_date)
options:
count: 0
wait_for_completion: True
disable_action: True
filters:
- filtertype: pattern
kind: prefix
value: logstash-
- filtertype: age
source: creation_date
direction: older
unit: days
unit_count: 10
-------------
[[ex_restore]]
== restore
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: restore
description: >-
Restore all indices in the most recent curator-* snapshot with state
SUCCESS. Wait for the restore to complete before continuing. Do not skip
the repository filesystem access check. Use the other options to define
the index/shard settings for the restore.
options:
repository:
# If name is blank, the most recent snapshot by age will be selected
name:
# If indices is blank, all indices in the snapshot will be restored
indices:
include_aliases: False
ignore_unavailable: False
include_global_state: False
partial: False
rename_pattern:
rename_replacement:
extra_settings:
wait_for_completion: True
skip_repo_fs_check: True
disable_action: True
filters:
- filtertype: pattern
kind: prefix
value: curator-
- filtertype: state
state: SUCCESS
-------------
[[ex_rollover]]
== rollover
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: rollover
description: >-
Rollover the index associated with alias 'aliasname', which should be in the
format of prefix-000001 (or similar), or prefix-YYYY.MM.DD-1.
options:
disable_action: True
name: aliasname
conditions:
max_age: 1d
max_docs: 1000000
max_size: 50g
extra_settings:
index.number_of_shards: 3
index.number_of_replicas: 1
-------------
[[ex_shrink]]
== shrink
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: shrink
description: >-
Shrink logstash indices older than 21 days on the node with the most
available space, excluding the node named 'not_this_node'.
Delete each source index after successful shrink, then reroute the shrunk
index with the provided parameters.
options:
disable_action: True
ignore_empty_list: True
shrink_node: DETERMINISTIC
node_filters:
permit_masters: False
exclude_nodes: ['not_this_node']
number_of_shards: 1
number_of_replicas: 1
shrink_prefix:
shrink_suffix: '-shrink'
delete_after: True
post_allocation:
allocation_type: include
key: node_tag
value: cold
wait_for_active_shards: 1
extra_settings:
settings:
index.codec: best_compression
wait_for_completion: True
wait_for_rebalance: True
wait_interval: 9
max_wait: -1
filters:
- filtertype: pattern
kind: prefix
value: logstash-
- filtertype: age
source: creation_date
direction: older
unit: days
unit_count: 21
-------------
[[ex_snapshot]]
== snapshot
[source,yaml]
-------------
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: snapshot
description: >-
Snapshot logstash- prefixed indices older than 1 day (based on index
creation_date) with the default snapshot name pattern of
'curator-%Y%m%d%H%M%S'. Wait for the snapshot to complete. Do not skip
the repository filesystem access check. Use the other options to create
the snapshot.
options:
repository:
# Leaving name blank will result in the default 'curator-%Y%m%d%H%M%S'
name:
ignore_unavailable: False
include_global_state: True
partial: False
wait_for_completion: True
skip_repo_fs_check: False
disable_action: True
filters:
- filtertype: pattern
kind: prefix
value: logstash-
- filtertype: age
source: creation_date
direction: older
unit: days
unit_count: 1
-------------
|