Metrics Platform/Creating a Stream Configuration

From Wikitech
Jump to navigation Jump to search


Metrics Platform streams are declared in $wgEventStreams, like other Event Platform streams, but with

  • the stream's schema_title property set to /analytics/mediawiki/client/metrics_event, and with
  • a metrics_platform_client element included in the stream's producers property.

The metrics_platform_client element, in turn, should include the following properties:

  • events: the names or prefixes of events that should be dispatched to the stream (e.g., foo matches foo, foobar, etc.)
  • provide_values: the contextual values that should be added into the event before it is dispatched to this stream. See metrics_platform_client.schema.json for a complete list of contextual values.

and may optionally include the following property:

  • curation: ...

These elements are illustrated in the ext-EventStreamConfig.php template below.

General documentation for Event Platform stream configuration is at Event Platform/Stream Configuration.

Illustrative Templates

Declaring a Metrics Platforms stream in mediawiki-config/wmf-config/ext-EventStreamConfig.php:

<?php

    // …
    
    'wgEventStreams' => [

        // Define the stream for all wikis in production and on the Beta
        // Cluster, including metawiki, which means that you can observe events
        // flowing on it using the eventstreams-ui tool.
        'default' => [
            'my.stream' => [
            
                // The Metrics Platform monoschema.
                'schema_title' => 'analytics/mediawiki/client/metrics_event',
    			
    			'destination_event_service' => 'eventgate-analytics-external',
    
                'producers' => [
                    'metrics_platform_client' => [
    
                        // The names or prefixes of events that should be dispatched
                        // to the stream, e.g. 'foo' matches 'foo', 'foobar', etc.
                        'events' => [],
                        
                        // The contextual values that should be mixed into the event
                        // before it is dispatched to this stream.
                        'provide_values' => [
                            'agent_client_platform',
                            'agent_client_platform_family',
                            'mediawiki_database',
                            'mediawiki_is_production',
                        ],
                    ],
                ],
            
                // Do not dispatch events to this stream by default.
                'sample' => [
                    'unit' => 'pageview',
                    'rate' => 0,
                ],
            ],
        ],
        
        // …
        
        // Dispatch all events to this stream on foowiki. Note well that this
        // could also be a dblist, e.g. group0, group1, etc.
        '+foowiki' => [
            'my.stream' => [
                'sample' => [
                    'rate' => 1,
                ],
            ],
        ],
    ],
    
    // …

The corresponding declaration in mediawiki-config/wmf-config/InitialiseSettings-labs.php:

<?php

    // …
    
    'wgEventStreams' => [

        // …

        // As above, dispatch all events to this stream on foowiki on the Beta
        // Cluster.
        '+foowiki' => [
            'my.stream' => [
                'sample' => [
                    'rate' => 1,
                ],
            ],
        ],

        // …

    ],
    
    // …