Skip to content

apm-data: explicit map of timestamp.us to long#143173

Merged
endorama merged 12 commits intoelastic:mainfrom
endorama:apm-data-timestampus_mapping
Mar 3, 2026
Merged

apm-data: explicit map of timestamp.us to long#143173
endorama merged 12 commits intoelastic:mainfrom
endorama:apm-data-timestampus_mapping

Conversation

@endorama
Copy link
Copy Markdown
Contributor

@endorama endorama commented Feb 26, 2026

We recently discovered a bug related to a missing mapping: elastic/apm-server#20496

This PR fixes it by adding the proper mapping in template for field timestamp.us on traces data streams.

Bumped resource version to ensure upgrade path works too.

Closes elastic/apm-server#20496

We would like to backport this fix to 8.19, 9.2 9.3, but I'm not sure how to trigger the automation.

@endorama
Copy link
Copy Markdown
Contributor Author

endorama commented Feb 27, 2026

I tested 2 different paths for this fix:

  1. Sending data to the development build that includes this fix
  2. Upgrading from 9.3.1 to the development build that includes this fix

The setup was APM Server => Logstash => Elasticsearch, to trigger the bug.

What we want is for timestamp.us to be mapped always as long.

Checking the type of timestamp.us field in the current version gives:

❯ curl -s "http://localhost:9200/_field_caps?fields=timestamp.us&index=traces-apm*&pretty"
{
  "indices" : [
    ".ds-traces-apm-default-2026.02.26-000001"
  ],
  "fields" : {
    "timestamp.us" : {
      "float" : {
        "type" : "float",
        "metadata_field" : false,
        "searchable" : true,
        "aggregatable" : true
      }
    },
    "timestamp" : {
      "object" : {
        "type" : "object",
        "metadata_field" : false,
        "searchable" : false,
        "aggregatable" : false
      }
    }
  }
}

Using the development build with this fix

An example Java application sending a single trace on requests to / was my telemetry generator.

Running the development build, we can see that the type has changed to long.

❯ curl -s "http://localhost:9200/_field_caps?fields=timestamp.us&index=traces-apm*&pretty"
{
  "indices" : [
    ".ds-traces-apm-default-2026.02.26-000001"
  ],
  "fields" : {
    "timestamp.us" : {
      "long" : {
        "type" : "long",
        "metadata_field" : false,
        "searchable" : true,
        "aggregatable" : true
      }
    },
    "timestamp" : {
      "object" : {
        "type" : "object",
        "metadata_field" : false,
        "searchable" : false,
        "aggregatable" : false
      }
    }
  }
}

Upgrading from 9.3.1 to the development build with this fix

❯ curl -s "http://localhost:9200/_field_caps?fields=timestamp.us&index=traces-apm*&pretty"

{
  "fields": {
    "timestamp": {
      "object": {
        "aggregatable": false,
        "metadata_field": false,
        "searchable": false,
        "type": "object"
      }
    },
    "timestamp.us": {
      "float": {
        "aggregatable": true,
        "metadata_field": false,
        "searchable": true,
        "type": "float"
      }
    }
  },
  "indices": [
    ".ds-traces-apm-default-2026.02.27-000001"
  ]
}

after upgrading to development version:

{
  "fields": {
    "timestamp": {
      "object": {
        "aggregatable": false,
        "metadata_field": false,
        "searchable": false,
        "type": "object"
      }
    },
    "timestamp.us": {
      "long": {
        "aggregatable": true,
        "metadata_field": false,
        "searchable": true,
        "type": "long"
      }
    }
  },
  "indices": [
    ".ds-traces-apm-default-2026.02.27-000002"
  ]
}

We can observe a rollover happened from .ds-traces-apm-default-2026.02.27-000001 to .ds-traces-apm-default-2026.02.27-000002 and the field from float is now long.

@endorama endorama marked this pull request as ready for review February 27, 2026 12:32
@endorama endorama requested a review from a team as a code owner February 27, 2026 12:32
@elasticsearchmachine elasticsearchmachine added the needs:triage Requires assignment of a team area label label Feb 27, 2026
github-merge-queue bot pushed a commit to elastic/apm-server that referenced this pull request Feb 27, 2026
…arch output is used (#20508)

* Known issue - timestamp.us as float

Add known issue for elastic/elasticsearch#143173 and #20496

* Apply suggestion from @lucabelluccini

* Apply suggestion from @lucabelluccini

* Apply suggestion from @lucabelluccini
@endorama endorama added Team:obs-ds-intake-services Meta label for Observability Intake Services team >bug labels Feb 27, 2026
@elasticsearchmachine elasticsearchmachine removed the Team:obs-ds-intake-services Meta label for Observability Intake Services team label Feb 27, 2026
@endorama endorama added the Team:obs-ds-intake-services Meta label for Observability Intake Services team label Feb 27, 2026
@elasticsearchmachine elasticsearchmachine removed the Team:obs-ds-intake-services Meta label for Observability Intake Services team label Feb 27, 2026
@endorama endorama self-assigned this Feb 27, 2026
@endorama endorama added the :StorageEngine/Data streams Data streams and their lifecycles label Feb 27, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@elasticsearchmachine elasticsearchmachine removed the needs:triage Requires assignment of a team area label label Feb 27, 2026
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Hi @endorama, I've created a changelog YAML for you.

Copy link
Copy Markdown
Member

@carsonip carsonip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code change lgtm, 1 nit on test

@endorama
Copy link
Copy Markdown
Contributor Author

endorama commented Mar 3, 2026

part-2 checks are successful: https://buildkite.com/elastic/elasticsearch-pull-request/builds/124971/steps/canvas?sid=019cb3a4-e794-480c-9a62-3750dc7c7187&tab=output

The failures looks unrelated to current changes. Updating main.

@endorama endorama added auto-backport Automatically create backport pull requests when merged v9.3.2 v8.19.13 v9.2.7 labels Mar 3, 2026
@endorama endorama enabled auto-merge (squash) March 3, 2026 15:45
@endorama endorama merged commit 9b887f1 into elastic:main Mar 3, 2026
31 of 34 checks passed
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

💔 Backport failed

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 143173

GalLalouche pushed a commit to GalLalouche/elasticsearch that referenced this pull request Mar 3, 2026
* add test to verify timestamp.us mapping and timestamp.us coercion behavior

* explicitly map timestamp.us to long

* apm-data: bump resource version
szybia added a commit to szybia/elasticsearch that referenced this pull request Mar 3, 2026
…locations

* upstream/main: (51 commits)
  ESQL: Remaining serialization tests (elastic#143470)
  Eagerly release resources in `TransportAwaitClusterStateVersionAppliedAction` (elastic#143477)
  Stop and relocate sliced reindex on shutdown (elastic#143183)
  Documentation for query_vector base64 parameter (elastic#142675)
  ES|QL: Fix LIMIT after all columns are dropped (elastic#143463)
  Update docs-build.yml (elastic#142958)
  Fix KnnIndexTester to work with byte vectors (elastic#143493)
  Fix IndexInputUtils.withSlice to produce native-safe MemorySegments on Java 21 (elastic#143479)
  CPS fix: include only relevant projects in the search response metadata (elastic#143367)
  apm-data: explicit map of timestamp.us to long (elastic#143173)
  [Inference API] Add custom headers for Azure OpenAI Service (elastic#142969)
  ESQL: Add name IDs to golden tests and fix synthetic names (elastic#143450)
  Add getUnavailableShards to BaseBroadcastResponse (elastic#143406)
  Add description to reindex API without sensitive info (elastic#143112)
  SQL: fix CLI tests (elastic#143451)
  ES|QL: Add note of future removal of FORK implicit LIMIT (elastic#143457)
  [Test] Randomly disable doc values skippers in time-series indices (elastic#143389)
  Improve pattern text downgrade license test (elastic#143102)
  [Transform] Stop transforms at the end of tests (elastic#139783)
  Mute org.elasticsearch.compute.lucene.read.ValueSourceReaderTypeConversionTests testLoadAll elastic#143471
  ...
shmuelhanoch pushed a commit to shmuelhanoch/elasticsearch that referenced this pull request Mar 4, 2026
* add test to verify timestamp.us mapping and timestamp.us coercion behavior

* explicitly map timestamp.us to long

* apm-data: bump resource version
endorama added a commit to endorama/elasticsearch that referenced this pull request Mar 4, 2026
* add test to verify timestamp.us mapping and timestamp.us coercion behavior

* explicitly map timestamp.us to long

* apm-data: bump resource version

(cherry picked from commit 9b887f1)
endorama added a commit to endorama/elasticsearch that referenced this pull request Mar 4, 2026
* add test to verify timestamp.us mapping and timestamp.us coercion behavior

* explicitly map timestamp.us to long

* apm-data: bump resource version

(cherry picked from commit 9b887f1)
@endorama
Copy link
Copy Markdown
Contributor Author

endorama commented Mar 4, 2026

💚 All backports created successfully

Status Branch Result
9.3
9.2
8.19

Questions ?

Please refer to the Backport tool documentation

endorama added a commit to endorama/elasticsearch that referenced this pull request Mar 4, 2026
* add test to verify timestamp.us mapping and timestamp.us coercion behavior

* explicitly map timestamp.us to long

* apm-data: bump resource version

(cherry picked from commit 9b887f1)

# Conflicts:
#	x-pack/plugin/apm-data/src/main/resources/resources.yaml
endorama added a commit that referenced this pull request Mar 4, 2026
* add test to verify timestamp.us mapping and timestamp.us coercion behavior

* explicitly map timestamp.us to long

* apm-data: bump resource version

(cherry picked from commit 9b887f1)
endorama added a commit that referenced this pull request Mar 4, 2026
* add test to verify timestamp.us mapping and timestamp.us coercion behavior

* explicitly map timestamp.us to long

* apm-data: bump resource version

(cherry picked from commit 9b887f1)
endorama added a commit that referenced this pull request Mar 4, 2026
* add test to verify timestamp.us mapping and timestamp.us coercion behavior

* explicitly map timestamp.us to long

* apm-data: bump resource version

(cherry picked from commit 9b887f1)

# Conflicts:
#	x-pack/plugin/apm-data/src/main/resources/resources.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged backport pending >bug :StorageEngine/Data streams Data streams and their lifecycles Team:StorageEngine v8.19.13 v9.2.7 v9.3.2 v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broken waterfall view due to wrong mapping of timestamp.us field

4 participants