Page MenuHomePhabricator

Strange elasticsearch mapping types for unix epoch dates
Closed, InvalidPublic

Description

Hello,
our goal is to visualize phabricator events using Kibana and/or Grafana using elasticsearch as a data source. Phabricator provides the functionality to feed elasticsearch with events, so we have configured search.elastic.host and search.elastic.namespace, and events started populating the phabricator index. However, we are not capable of visualizing the events in the aforementioned tools. After thorough investigation, we noticed that the timestamp fields that we selected as timepickers (dateCreated and _timestamp to be precise) contain unix epoch values in seconds. Additionally, <_timestamp> and <dateCreated> fields are mapped as "string" type after indexing and <when> fields mapped as "long" type. These conditions make elasticsearch ignore these fields as timestamps and the aforementioned tools unable to parse datetime information out of them. Let me suggest the following changes:

  1. ensure that fields that contain timestamp fields to be mapped as "date" type fields in Elasticsearch. Especially for dateCreated this seems to be hardcoded in src/applications/search/engine/PhabricatorElasticSearchEngine.php
  2. unix epoch timestamps to be converted in a built-in ISO date format that is recognized by current stable Elasticsearch releases. That way, an elasticsearch user who wants to visualize these events in Kibana/Grafana will not need to modify the date format of the field. Notice that some built-in date formats like epoch_second and epoch_millis formats are only supported in Elasticsearch 2 and above.

That way, theoretically, there will be no need for changing the mapping of phabricator index types (TASK, DREV, CMIT) and elasticsearch will index automatically the events with the correct date types.

[1] https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html

Best regards,
Kostis

Event Timeline

kosfar raised the priority of this task from to Needs Triage.
kosfar updated the task description. (Show Details)
kosfar changed the edit policy from "All Users" to "Custom Policy".
kosfar added a project: Bug Report.
kosfar added a subscriber: kosfar.

Can you provide more details on exactly how this is a bug?

What actions can I take from the Phabricator UI to produce unexpected results?

Hi epriestley,
I switched this to Feature Request and added Elasticsearch on the projects lists.

When submitting a feature request, please describe the root problem you are trying to solve. See Contributing Feature Requests.

This describes a narrow technical problem which is almost certainly very distant (and very different) from whatever root problem you are facing. There may be a better way that you can accomplish the overall goal you are trying to accomplish, but we can't help you find it if you don't tell us your big-picture goal.

Beyond Contributing Feature Requests, see also How To Ask Questions The Smart Way, XY Problem, etc.

Hi epriestley,
just added all relevant details. Everything is on the task now.

chad claimed this task.
chad added a subscriber: chad.

our goal is to visualize phabricator events using Kibana and/or Grafana using elasticsearch as a data source.

We don't provide support for custom development. You'll want to maintain a local fork or patch for you needs.

Sorry to say, but this has nothing to do with custom development. As long as you want to feed elasticsearch with phabricator events, my feature request/suggestion was to do it in a way that is usable by elasticsearch-friendly tools without resorting to hacks and customizations on the elasticsearch side ( which is ok to do at some extent, but right now leaves phabricator in a state requesting to fix index mappings on the elasticsearch side - at least).

Integrating Phabricator into an external (unsupported) tool is considered by us to be custom application development. We only can take upstreamable feature requests that state a core problem when using Phabricator itself. I don't know what these apps are nor why you want to use them. It could be there are already upstream plans to provide similar features.