Skip to content

Counter field validation still occurs after downgrading tsdb data stream #96170

@martijnvg

Description

@martijnvg

Tsdb is more picky about what aggregations are allowed to be executed on counter fields. For example a sum aggregation isn't allowed to run on a counter field. There is support to opt out of tsdb. However even after opting out of tsdb shard failures may still occur. This is because the data stream is downgraded but not any pre-existing tsdb indices.

Reproduction:

PUT _index_template/1
{
  "index_patterns": [
    "test*"
  ],
  "template": {
    "mappings": {
      "properties": {
          "my_field": {
              "time_series_dimension": true,
              "type": "keyword"
          },
          "another_field": {
            "type": "long",
            "time_series_metric": "counter"
          }
      }
    }
  },
  "data_stream": {}
}


POST test2/_doc?refresh
{
  "@timestamp": "2023-05-16T11:49:50.599Z",
  "my_field": "value",
  "another_field": 656
}

GET test2/_search
{
    "size": 0,
    "aggs": {
        "test": {
            "sum": {
                "field": "another_field"
            }
        }
    }
}


PUT _index_template/1
{
  "index_patterns": [
    "test*"
  ],
  "template": {
    "settings": {
      "index": {
        "mode": "time_series"
      }
    },
    "mappings": {
      "properties": {
          "my_field": {
              "time_series_dimension": true,
              "type": "keyword"
          },
          "another_field": {
            "type": "long",
            "time_series_metric": "counter"
          }
      }
    }
  },
  "data_stream": {}
}

POST test2/_rollover

POST test2/_doc?refresh
{
  "@timestamp": "2023-05-16T16:23:51.659Z",
  "my_field": "value",
  "another_field": 6566
}

GET test2/_search
{
    "size": 0,
    "aggs": {
        "test": {
            "sum": {
                "field": "another_field"
            }
        }
    }
}

PUT _index_template/1
{
  "index_patterns": [
    "test*"
  ],
  "template": {
    "settings": {
      "index": {
        "mode": null
      }
    },
    "mappings": {
      "properties": {
          "my_field": {
              "time_series_dimension": true,
              "type": "keyword"
          },
          "another_field": {
            "type": "long",
            "time_series_metric": "counter"
          }
      }
    }
  },
  "data_stream": {}
}

POST test2/_rollover

POST test2/_doc?refresh
{
  "@timestamp": "2023-05-16T16:23:51.659Z",
  "my_field": "value",
  "another_field": 6566
}

GET test2/_search
{
    "size": 0,
    "aggs": {
        "test": {
            "sum": {
                "field": "another_field"
            }
        }
    }
}

The expected behaviour is that the last search succeeds but it fails with a shard failure:

{
    "took": 4,
    "timed_out": false,
    "_shards": {
        "total": 3,
        "successful": 2,
        "skipped": 0,
        "failed": 1,
        "failures": [
            {
                "shard": 0,
                "index": ".ds-test2-2023.05.16-000002",
                "node": "e9y5C7zmRy6I-3j5aW1vEA",
                "reason": {
                    "type": "illegal_argument_exception",
                    "reason": "Field [another_field] of type [long] is not supported for aggregation [sum]"
                }
            }
        ]
    },
    "hits": {
        "total": {
            "value": 2,
            "relation": "eq"
        },
        "max_score": null,
        "hits": []
    },
    "aggregations": {
        "test": {
            "value": 7222
        }
    }
}

Note that this shard failure could be ignored.

Metadata

Metadata

Assignees

Labels

:StorageEngine/TSDBYou know, for Metrics>bugTeam:AnalyticsMeta label for analytical engine team (ESQL/Aggs/Geo)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions