Configuring the log curator

You can configure log retention time. That is, you can specify how long the default Elasticsearch log store keeps indices by configuring a separate retention policy for each of the three log sources: infrastructure logs, application logs, and audit logs. For instructions, see Configuring log retention time.

Configuring log retention time is recommended method for curating log data: It works with both the current data model and the previous data model from OKD 4.4 and earlier.

Optionally, to remove Elasticsearch indices that use the data model from OKD 4.4 and earlier, you can also use the Elasticsearch Curator. The following sections explain how to use the Elasticsearch Curator.

The Elasticsearch Curator is deprecated in OKD 4.7 (OpenShift Logging 5.0) and will be removed in OpenShift Logging 5.1.

Configuring the Curator schedule

You can specify the schedule for Curator using the Cluster Logging custom resource created by the OpenShift Logging installation.

The Elasticsearch Curator is deprecated in OKD 4.7 (OpenShift Logging 5.0) and will be removed in OpenShift Logging 5.1.

Prerequisites

  • Cluster logging and Elasticsearch must be installed.

Procedure

To configure the Curator schedule:

  1. Edit the ClusterLogging custom resource in the openshift-logging project:

    1. $ oc edit clusterlogging instance
    1. apiVersion: "logging.openshift.io/v1"
    2. kind: "ClusterLogging"
    3. metadata:
    4. name: "instance"
    5. ...
    6. curation:
    7. curator:
    8. schedule: 30 3 * * * (1)
    9. type: curator
    1Specify the schedule for Curator in cron format.

    The time zone is set based on the host node where the Curator pod runs.

Configuring Curator index deletion

You can configure Elasticsearch Curator to delete Elasticsearch data that uses the data model prior to OKD version 4.5. You can configure per-project and global settings. Global settings apply to any project not specified. Per-project settings override global settings.

The Elasticsearch Curator is deprecated in OKD 4.7 (OpenShift Logging 5.0) and will be removed in OpenShift Logging 5.1.

Prerequisites

  • Cluster logging must be installed.

Procedure

To delete indices:

  1. Edit the OKD custom Curator configuration file:

    1. $ oc edit configmap/curator
  2. Set the following parameters as needed:

    1. config.yaml: |
    2. project_name:
    3. action
    4. unit:value

    The available parameters are:

    Table 1. Project options
    Variable NameDescription

    project_name

    The actual name of a project, such as myapp-devel. For OKD operations logs, use the name .operations as the project name.

    action

    The action to take, currently only delete is allowed.

    unit

    The period to use for deletion, days, weeks, or months.

    value

    The number of units.

    Table 2. Filter options
    Variable NameDescription

    .defaults

    Use .defaults as the project_name to set the defaults for projects that are not specified.

    .regex

    The list of regular expressions that match project names.

    pattern

    The valid and properly escaped regular expression pattern enclosed by single quotation marks.

For example, to configure Curator to:

  • Delete indices in the myapp-dev project older than 1 day

  • Delete indices in the myapp-qe project older than 1 week

  • Delete operations logs older than 8 weeks

  • Delete all other projects indices after they are 31 days old

  • Delete indices older than 1 day that are matched by the ^project\..+\-dev.*$ regex

  • Delete indices older than 2 days that are matched by the ^project\..+\-test.*$ regex

Use:

  1. config.yaml: |
  2. .defaults:
  3. delete:
  4. days: 31
  5. .operations:
  6. delete:
  7. weeks: 8
  8. myapp-dev:
  9. delete:
  10. days: 1
  11. myapp-qe:
  12. delete:
  13. weeks: 1
  14. .regex:
  15. - pattern: '^project\..+\-dev\..*$'
  16. delete:
  17. days: 1
  18. - pattern: '^project\..+\-test\..*$'
  19. delete:
  20. days: 2

When you use months as the $UNIT for an operation, Curator starts counting at the first day of the current month, not the current day of the current month. For example, if today is April 15, and you want to delete indices that are 2 months older than today (delete: months: 2), Curator does not delete indices that are dated older than February 15; it deletes indices older than February 1. That is, it goes back to the first day of the current month, then goes back two whole months from that date. If you want to be exact with Curator, it is best to use days (for example, delete: days: 30).