# This is am example configuration file for Pivot, here you can add data sources as well as configure Pivot settings
# You can start by using this sample config by running `cp config_sample.yaml config.yaml`

# The port on which the Pivot server will listen on
port: 9090

# Run in verbose mode and print the queries sent to the server
#verbose: true

# A Druid broker node that can serve data (only used if you have Druid based data source)
#druidHost: localhost:8082

# A timeout for the Druid queries in ms (default: 30000 = 30 seconds)
timeout: 30000

#sourceListRefreshOnLoad: true
#sourceListRefreshInterval: 0 #10000

auth: auth.js

#headerBackground: '#ffc000'
#hideGitHubIcon: true

# The data sources that you have configured, these will appear, in order, inside the navigation menu of Pivot
# In general there can be two types of 'engine':
#   - native: a JSON file that is crunched within plywood itself (useful for small datasets and testing)
#   - druid: a Druid dataSource
dataSources:
  - name: static-imply-logs # This will go into the URL so no fancy characters allowed

    # This is the title that will grace this data source in the the menus
    title: Imply Logs

    # Use the native engine, all calculations will be done in Node.JS. Good for up to 100k rows of data.
    engine: native

    # The file representing the datasource relative to repo root
    source: ../../stats/bucketlogs/imply-all.json
    # This datasource was scraped using https://github.com/implydata/wikiticker
    # GitHub does not like large files so only a sampled file is checked in
    # There is also a non-sampled file with the filter: isAnonymous == true applied, to use it set:
    # source: assets/data/wikiticker-2015-09-12-anonymous.json
    # Run `assets/data-raw/process-wikiticker-2015-09-12` to get the full example file

    # The refresh rule describes how often the data source looks for new data. Default: 'query'/PT1M (every minute)
    # In this case it has to be fixed since this data source is static
    refreshRule:
      rule: query
      refresh: PT1H

    # The default timezone for this dataset to operate in defaults to UTC
    #defaultTimezone: Asia/Kathmandu

    # The default duration for the time filter (if not set P1D is used)
    defaultDuration: P1D

    # How the dataset should be introspected
    # possible options are:
    # * none - Do not do any introspection, take what is written in the config as the rule of law.
    # * no-autofill - Introspect the datasource but do not automatically generate dimensions or measures
    # * autofill-dimensions-only - Introspect the datasource, automatically generate dimensions only
    # * autofill-measures-only - Introspect the datasource, automatically generate measures only
    # * autofill-all - (default) Introspect the datasource, automatically generate dimensions and measures
    introspection: autofill-dimensions-only

    # The list of dimensions defined in the UI. The order here will be reflected in the UI
    dimensions:

      - name: time
        type: TIME

      - name: month
        expression: $time.timeBucket('P1M', 'Etc/UTC')

      - name: quarter
        expression: $time.timeBucket('P3M', 'Etc/UTC')

      - name: year
        expression: $time.timeBucket('P1Y', 'Etc/UTC')

      - name: statusCode

    # The list of measures defined in the UI. The order here will be reflected in the UI
    measures:
      # A general measure looks like so:
      #
      # name: avg_revenue
      # ^ the name of the dimension as used in the URL (you should try not to change these)
      #
      # title: Average Revenue
      # ^ (optional) the human readable title. If not set a title is generated from the 'name'
      #
      # expression: $main.sum($revenue) / $main.sum($volume) * 10
      # ^ (optional) the Plywood bucketing expression for this dimension.
      #   Usually defaults to '$main.sum($name)' but if the name contains 'min' or 'max' will use that as the aggregate instead of sum.
      #   this is the place to define your fancy formulas

      - name: count
        title: Count
        expression: $main.count()

      - name: count200
        title: Count200
        expression: $main.filter($statusCode == 200).count()

      - name: uniqueIp
        title: Unique IP
        expression: $main.countDistinct($remoteIp)

      - name: countPerIp
        title: Count per IP
        expression: $main.count() / $main.countDistinct($remoteIp)

      - name: count200PerIp
        title: Count200 per IP
        expression: $main.filter($statusCode == 200).count() / $main.countDistinct($remoteIp)

      - name: uniqueUserAgent
        title: Unique User Agent
        expression: $main.countDistinct($userAgent)

      - name: avgObjectSize
        expression: $main.average($objectSize)

      - name: avgStatusCode
        expression: $main.average($statusCode)

      - name: maxStatusCode
        expression: $main.max($statusCode)


linkViewConfig:
  title: Imply Clarity
  linkItems:
    - name: 'd1'
      title: 'Druid Logz'
      description: 'I like logs'
      group: 'Logz'
      dataSource: 'static-imply-logs'
      essence:
        pinnedDimensions: ['statusCode']
        selectedMeasures: ['count', 'countPerIp', 'uniqueIp']
        splits: 'time'

    - name: 'd2'
      title: 'Druid Logz part 2'
      description: 'I like logs also (statusCode)'
      group: 'Logz'
      dataSource: 'static-imply-logs'
      essence:
        pinnedDimensions: ['statusCode']
        selectedMeasures: ['count', 'countPerIp', 'uniqueIp']
        splits: ['statusCode']

    - name: 'b1'
      title: 'Blog Logz'
      description: 'I like logs'
      group: 'Blogs'
      dataSource: 'static-imply-logs'
      essence:
        pinnedDimensions: ['statusCode']
        selectedMeasures: ['count', 'countPerIp', 'uniqueIp']
        splits: []

    - name: 'b2'
      title: 'Blog Logz part 2'
      description: 'I like logs also (versionExtract)'
      group: 'Blogs'
      dataSource: 'static-imply-logs'
      essence:
        pinnedDimensions: ['versionExtract']
        selectedMeasures: ['count', 'countPerIp', 'uniqueIp']
        splits: []
