[
    {
        "apiVersion": "influxdata.com/v2alpha1",
        "kind": "Task",
        "metadata": {
            "name": "elegant-archimedes-94d001"
        },
        "spec": {
            "every": "1h",
            "name": "Transform analytics to counts",
            "query": "errors =\n    from(bucket: \"analytics\")\n        |> range(start: -task.every)\n        |> filter(fn: (r) => r._measurement == \"build_error\" and r._field == \"package\")\n        |> reduce(\n            fn: (r, accumulator) =>\n                ({\n                    pkg: r._value,\n                    _value: 1 + accumulator._value,\n                    _time: r._time,\n                    _field: r._field,\n                    _measurement: r._measurement,\n                }),\n            identity: {\n                pkg: \"\",\n                _value: 0,\n                _time: now(),\n                _measurement: \"\",\n                _field: \"\",\n            },\n        )\n        |> keep(\n            columns: [\n                \"_value\",\n                \"pkg\",\n                \"_time\",\n                \"_measurement\",\n                \"_field\",\n            ],\n        )\n        |> to(bucket: \"analytics_downsampled\")\n\nformula =\n    from(bucket: \"analytics\")\n        |> range(start: -task.every)\n        |> filter(fn: (r) => r._measurement == \"formula_install\" and r._field == \"package\")\n        |> reduce(\n            fn: (r, accumulator) =>\n                ({\n                    pkg: r._value,\n                    _value: 1 + accumulator._value,\n                    _time: r._time,\n                    _field: r._field,\n                    _measurement: r._measurement,\n                }),\n            identity: {\n                pkg: \"\",\n                _value: 0,\n                _time: now(),\n                _measurement: \"\",\n                _field: \"\",\n            },\n        )\n        |> keep(\n            columns: [\n                \"_value\",\n                \"pkg\",\n                \"_time\",\n                \"_measurement\",\n                \"_field\",\n            ],\n        )\n        |> to(bucket: \"analytics_downsampled\")\n\nreqFormula =\n    from(bucket: \"analytics\")\n        |> range(start: -task.every)\n        |> filter(\n            fn: (r) =>\n                r._measurement == \"formula_install\" and r._field == \"package\" and r.on_request\n                    ==\n                    \"true\",\n        )\n        |> reduce(\n            fn: (r, accumulator) =>\n                ({\n                    pkg: r._value,\n                    _value: 1 + accumulator._value,\n                    _time: r._time,\n                    _field: r._field,\n                    _measurement: r._measurement,\n                    measure_col: \"formula_install_on_request\",\n                }),\n            identity: {\n                pkg: \"\",\n                _value: 0,\n                _time: now(),\n                _measurement: \"\",\n                measure_col: \"formula_install_on_request\",\n                _field: \"\",\n            },\n        )\n        |> keep(\n            columns: [\n                \"_value\",\n                \"pkg\",\n                \"_time\",\n                \"_measurement\",\n                \"measure_col\",\n                \"_field\",\n            ],\n        )\n        |> to(bucket: \"analytics_downsampled\", measurementColumn: \"measure_col\")\n\ncasks =\n    from(bucket: \"analytics\")\n        |> range(start: -task.every)\n        |> filter(fn: (r) => r._measurement == \"cask_install\" and r._field == \"package\")\n        |> reduce(\n            fn: (r, accumulator) =>\n                ({\n                    pkg: r._value,\n                    _value: 1 + accumulator._value,\n                    _time: r._time,\n                    _field: r._field,\n                    _measurement: r._measurement,\n                }),\n            identity: {\n                pkg: \"\",\n                _value: 0,\n                _time: now(),\n                _measurement: \"\",\n                _field: \"\",\n            },\n        )\n        |> keep(\n            columns: [\n                \"_value\",\n                \"pkg\",\n                \"_time\",\n                \"_measurement\",\n                \"_field\",\n            ],\n        )\n        |> to(bucket: \"analytics_downsampled\")\n\n// Agregate analytics\noses =\n    from(bucket: \"analytics\")\n        |> range(start: -task.every)\n        |> filter(\n            fn: (r) =>\n                (r._measurement == \"formula_install\" or r._measurement == \"cask_install\")\n                    and\n                    r._field == \"os_name_and_version\",\n        )\n        |> reduce(\n            fn: (r, accumulator) =>\n                ({\n                    os: r._value,\n                    _value: 1 + accumulator._value,\n                    _time: r._time,\n                    _field: r._field,\n                    _measurement: r._measurement,\n                    measure_col: \"os_versions\",\n                }),\n            identity: {\n                os: \"\",\n                _value: 0,\n                _time: now(),\n                _measurement: \"\",\n                measure_col: \"os_versions\",\n                _field: \"\",\n            },\n        )\n        |> keep(\n            columns: [\n                \"_value\",\n                \"os\",\n                \"_time\",\n                \"_measurement\",\n                \"measure_col\",\n                \"_field\",\n            ],\n        )\n        |> to(bucket: \"analytics_downsampled\", measurementColumn: \"measure_col\")",
            "status": "active"
        }
    }
]