Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[reporting] combine usage requests #33593

Closed
jbudz opened this issue Mar 20, 2019 · 3 comments · Fixed by #34327
Closed

[reporting] combine usage requests #33593

jbudz opened this issue Mar 20, 2019 · 3 comments · Fixed by #34327
Assignees
Labels
Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@jbudz
Copy link
Member

jbudz commented Mar 20, 2019

Discussed briefly with @tsullivan, we can likely combine these requests https://github.com/elastic/kibana/blob/master/x-pack/plugins/reporting/server/usage/get_reporting_usage_collector.js#L129

@jbudz jbudz added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label Mar 20, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app

@tsullivan
Copy link
Member

In the current code, there are 3 queries, which each get job type data for a block of one of 3 time ranges: last 7 days, last 1 day, all time.

We can replace the 3 queries with one that uses a filters aggregation, and it will fetch the same data:

POST /.reporting-*/_search
{
  "size": 0,
  "aggs": {
    "date_ranges": {
      "filters": {
        "filters": {
          "last7": {
            "range": {
              "created_at": {
                "gte": "now-7d/d"
              }
            }
          },
          "last1": {
            "range": {
              "created_at": {
                "gte": "now-1d/d"
              }
            }
          },
          "all": {
            "match_all": {}
          }
        }
      },
      "aggs": {
        "jobTypes": {
          "terms": {
            "field": "jobtype",
            "size": 3
          }
        },
        "objectTypes": {
          "terms": {
            "field": "meta.objectType.keyword",
            "size": 3
          }
        },
        "layoutTypes": {
          "terms": {
            "field": "meta.layout.keyword",
            "size": 3
          }
        },
        "statusTypes": {
          "terms": {
            "field": "status",
            "size": 4
          }
        }
      }
    }
  }
}

@tsullivan
Copy link
Member

PR upcoming: #34327

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants