Page MenuHomePhabricator

Produce ECS formatted logstash logs to Event Platform, allowing them to be queried in the WMF Data Lake with SQL
Closed, ResolvedPublic

Description

T234565: Standardize the logstash logging format - ECS is trying to standardize the software logging format with the Elastic Common Schema. If we are able to produce these ECS logs with Event Platform, they would be automatically ingested into the WMF Data Lake.

This will allow people to use SQL to query the logs with Spark SQL (e.g,. spark3-sql, or pyspark, etc.) or Presto, and can be used for dashboarding with Superset.

This would be particularly useful if we are able to successfully migrate the MediaWiki logging format to ECS, as then MediaWiki software logs could be joined with other MediaWiki data in Hive.

Since the logs would be in Kafka with a well defined schema, they would also be consumable and reusable for other purposes, e.g. stream processing, anomaly detection and alerting, or ingestion into different data stores.


In 2021, Data Engineering and Observability teams met to discuss this idea. To accomplish this, we'd need:

Related Objects

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Marostegui triaged this task as Medium priority.Sep 24 2021, 4:29 AM

@colewhite, in https://phabricator.wikimedia.org/T288851#7456931 you said:

topics prefixed by rsyslog- will be automatically picked up by Logstash.

We've found using topic naming conventions for ingestion jobs to be brittle. We're moving towards using EventStreamConfig to automate configuring things like this. See: https://wikitech.wikimedia.org/wiki/Event_Platform/Stream_Configuration#consumers_and_producers

Example:

curl  'https://meta.wikimedia.org/w/api.php?action=streamconfigs&all_settings=1&streams=mediawiki.api-request' |  jq .
{
  "streams": {
    "mediawiki.api-request": {
      "topics": [
        "eqiad.mediawiki.api-request",
        "codfw.mediawiki.api-request"
      ],
      "stream": "mediawiki.api-request",
      "consumers": {
        "analytics_hadoop_ingestion": {
          "enabled": true,
          "job_name": "event_default"
        }
      },
      "canary_events_enabled": true,
      "topic_prefixes": [
        "eqiad.",
        "codfw."
      ],
      "destination_event_service": "eventgate-analytics",
      "schema_title": "mediawiki/api/request"
    }
  }
}

Here, we are declaring a consumer called 'analytics_hadoop_ingestion'. The settings for that consumer are arbitrary and specific to the consumer job. When that job runs, it requests all streams that have consumers.analytics_hadoop_ingestion declared, and uses those settings to import the data.

Logstash ingestion could probably do something similar, if the logging streams to import were declared in EventStreamConfig.

This would have been useful to debug T374662, aggregating the times out of elasticsearch is a bit hard as it would have to aggregate 50M requests through a single core (estimated time: multiple days due to repeated work for each pagination). Being able to throw hadoop at the problem would solve in a few 10s of minutes with an easy query.

This would be very useful for us to be able to understand if known problematic reusers (see: https://phabricator.wikimedia.org/T317001) are similarly saturating other data streams to avoid correcting issue behavior.

This would also help with some analysis in {T375146}

I've been told that this project would let me process Logstash data with SQL queries, and I would like that very much.

Ottomata renamed this task from Integrate Event Platform and ECS logs to Produce ECS formatted logstash logs to Event Platform, allowing them to be queried in the WMF Data Lake with SQL.Oct 10 2024, 1:16 PM
Ottomata updated the task description. (Show Details)
Ottomata updated the task description. (Show Details)

Assigning this to myself, since I am attempting to do this as part of T425087: Send JSON access logs for dumps.wikimedia.org to Kafka.

Change #1287374 had a related patch set uploaded (by Btullis; author: Btullis):

[operations/puppet@production] Configure rsyslog to forward 'dumps-http' messages to Kafka

https://gerrit.wikimedia.org/r/1287374

Change #1287407 had a related patch set uploaded (by Btullis; author: Btullis):

[operations/puppet@production] Configure nginx to log requests in ECS format to syslog

https://gerrit.wikimedia.org/r/1287407

Change #1295917 had a related patch set uploaded (by Btullis; author: Btullis):

[operations/puppet@production] logstash: Consume the ECS dumps webrequest stream from Kafka

https://gerrit.wikimedia.org/r/1295917

Change #1295922 had a related patch set uploaded (by Btullis; author: Btullis):

[operations/mediawiki-config@master] Declare the webrequest.dumps.dev0 stream in EventStreamConfig

https://gerrit.wikimedia.org/r/1295922

Change #1287407 merged by Btullis:

[operations/puppet@production] Configure nginx to log requests in ECS format to syslog

https://gerrit.wikimedia.org/r/1287407

Change #1296535 had a related patch set uploaded (by Btullis; author: Btullis):

[operations/puppet@production] dumps: web: Fix nginx ECS access log config so nginx can start

https://gerrit.wikimedia.org/r/1296535

Change #1296535 merged by Btullis:

[operations/puppet@production] dumps: web: Fix nginx ECS access log config so nginx can start

https://gerrit.wikimedia.org/r/1296535

Change #1287374 merged by Btullis:

[operations/puppet@production] Configure rsyslog to forward 'dumps_http' messages to Kafka

https://gerrit.wikimedia.org/r/1287374

Change #1296607 had a related patch set uploaded (by Btullis; author: Btullis):

[operations/puppet@production] kafka event platform logs - Strip the stray $!msg field

https://gerrit.wikimedia.org/r/1296607

Change #1296607 merged by Btullis:

[operations/puppet@production] kafka event platform logs - Strip the stray $!msg field

https://gerrit.wikimedia.org/r/1296607

Change #1295917 merged by Btullis:

[operations/puppet@production] logstash: Consume the ECS dumps webrequest stream from Kafka

https://gerrit.wikimedia.org/r/1295917

Change #1295922 merged by jenkins-bot:

[operations/mediawiki-config@master] Declare the webrequest.dumps.dev0 stream in EventStreamConfig

https://gerrit.wikimedia.org/r/1295922

Mentioned in SAL (#wikimedia-operations) [2026-06-03T16:37:16Z] <btullis@deploy1003> Started scap sync-world: Backport for [[gerrit:1295922|Declare the webrequest.dumps.dev0 stream in EventStreamConfig (T291645 T425087)]]

Mentioned in SAL (#wikimedia-operations) [2026-06-03T16:39:16Z] <btullis@deploy1003> btullis: Backport for [[gerrit:1295922|Declare the webrequest.dumps.dev0 stream in EventStreamConfig (T291645 T425087)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2026-06-03T16:44:32Z] <btullis@deploy1003> Finished scap sync-world: Backport for [[gerrit:1295922|Declare the webrequest.dumps.dev0 stream in EventStreamConfig (T291645 T425087)]] (duration: 07m 16s)

Change #1297214 had a related patch set uploaded (by Cwhite; author: Cwhite):

[operations/puppet@production] logstash: route all access logs to webrequest partition

https://gerrit.wikimedia.org/r/1297214

Change #1297214 merged by Cwhite:

[operations/puppet@production] logstash: route all access logs to webrequest partition

https://gerrit.wikimedia.org/r/1297214

Change #1297642 had a related patch set uploaded (by Btullis; author: Btullis):

[operations/puppet@production] dumps: web: Make nginx ECS log_format conform to the Event Platform schema

https://gerrit.wikimedia.org/r/1297642

btullis opened https://gitlab.wikimedia.org/repos/data-engineering/schemas-event-primary/-/merge_requests/56

Add source, destination, user_agent and http.response.body.bytes to the ECS schema

Setting T425087 as a parent task, since that was the use-case that made us finally make this happen.

Note that we bypassed EventGate for this specific use case, since we had no easy way for nginx to push its logs to an HTTP(S) endpoint.
In this case, rsyslog just parses the JSON payload for a meta.stream field. If it finds one, then it forwards to the kafka-logging clusters, using the a topic named:

$site.$meta.stream

This means that we don't get the schema validation features of eventgate for this particular use-case. However, it should work in general for other cases.

We will enable canary events on this stream shortly.

otto merged https://gitlab.wikimedia.org/repos/data-engineering/schemas-event-primary/-/merge_requests/56

Add source, destination, user_agent and http.response.body.bytes to the ECS schema

Change #1297642 merged by Btullis:

[operations/puppet@production] dumps: web: Make nginx ECS log_format conform to the Event Platform schema

https://gerrit.wikimedia.org/r/1297642

I think that we can call this done.

We now have a means for any application that can output to syslog to have Event Platform compatible ECS messages automatically routed to the Data Lake and, optionally, to Logstash as well.

We have an ECS compatible Event Platform schema in place.
We can choose whether an application uses EventGate for inbound messages, or bypasses it by using rsyslog directly.

We are tracking to promotion of the webrequest.dumps.dev0 eventstream to webrequest.dumps in T425087: Send JSON access logs for dumps.wikimedia.org to Kafka