0

We apply our index template using logstash's Elasticsearch output plugin. All of our index patterns are as such: "--" I am attempting to create an alias for each subsystem using alias filters, But the filters aren't being applied, causing every index to get all the aliases configured. (so subsystem A, get an alias of subsystem A and subsystem B and all other subsystems)

my template looks like this:

{
  "index_patterns" : "system-*",
  "version" : 1,
  "settings" : {
    "index.codec": "best_compression"
  },
  "aliases" : {
    "system" : {},
    
    "system-subsystem_a" : {
      "bool" : {
          "filter" : {
            "term" : {"Subsystem" : "subsystem_a"}
          }
      },

    "system-subsystem_b" : {
      "bool" : {
          "filter" : {
            "term" : {"Subsystem" : "subsystem_b"}
          }
      }
    }
}

I tried a few different variations and combinations (without using "bool" block. changing the term "Subsystem" to "Subsystem.keyword" and etc.) all came out with the same result.

I actually asked a similar question previously: elasticsearch templates - create alias from index_pattern

@ibexit suggested to create a template for each subsystem, but logstash's elasticsearch output plugin doesn't support multiple templates. I am hoping to avoid using the API. using a single file makes it easier for me to manage and quickly deploy test environments with docker-compose.

GKman
  • 503
  • 1
  • 5
  • 19

1 Answers1

0

Great start!! You're just missing the filter declaration in your alias:

{
  "index_patterns": "system-*",
  "version": 1,
  "settings": {
    "index.codec": "best_compression"
  },
  "aliases": {
    "system": {},
    "system-subsystem_a": {
      "filter": {                   
        "bool": {
          "filter": {
            "term": {
              "Subsystem": "subsystem_a"
            }
          }
        }
      }
    },
    "system-subsystem_b": {
      "filter": {
        "bool": {
          "filter": {
            "term": {
              "Subsystem": "subsystem_b"
            }
          }
        }
      }
    }
  }
}

And a simpler version, you don't need bool/filter at all:

{
  "index_patterns": "system-*",
  "version": 1,
  "settings": {
    "index.codec": "best_compression"
  },
  "aliases": {
    "system": {},
    "system-subsystem_a": {
      "filter": {
        "term": {
          "Subsystem": "subsystem_a"
        }
      }
    },
    "system-subsystem_b": {
      "filter": {
        "term": {
          "Subsystem": "subsystem_b"
        }
      }
    }
  }
}
Val
  • 207,596
  • 13
  • 358
  • 360