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

[Infra UI] Add log rate to metrics on Waffle Map #23834

Merged
merged 9 commits into from
Oct 17, 2018

Conversation

simianhacker
Copy link
Member

This PR adds the log rate metric to the waffle map.

image

This PR adds the log rate metric to the waffle map
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very useful, but the values themselves don't seem to be correct (see comment below).

@@ -59,6 +59,10 @@ const METRIC_FORMATTERS: MetricFormatters = {
},
[InfraMetricType.rx]: { formatter: InfraFormatterType.bits, template: '{{value}}/s' },
[InfraMetricType.tx]: { formatter: InfraFormatterType.bits, template: '{{value}}/s' },
[InfraMetricType.logRate]: {
formatter: InfraFormatterType.abbreviatedNumber,
template: '{{value}}/s',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the value really have the unit s? It depends on the histogram bucket size (AFAIK 1m on the waffle map right now). So we either use value with the same unit as the histogram bucket size or we use the normalized_value which should respect the 1s unit specified in the derivative agg, right?

I wonder if this also applies to the other rates like rx, which were already added previously?

Copy link
Member Author

@simianhacker simianhacker Oct 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I totally over looked the normalized value when I was setting this up originally. I just added a commit to fix this.

Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rates look more reasonable now, thank you. Unfortunately I stumbled upon something else below 😇

@@ -24,6 +25,9 @@ export function createPartitionBodies(
const { sourceConfiguration }: InfraNodeRequestOptions = nodeOptions;
const bodies: InfraESMSearchBody[] = [];
const numberOfPartitions: number = Math.ceil(totalNodes / NODE_REQUEST_PARTITION_SIZE);
const indices = nodeOptions.metrics.every(m => m.type === InfraMetricType.logRate)
? [sourceConfiguration.logAlias]
: [sourceConfiguration.logAlias, sourceConfiguration.metricAlias];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the graphql request contains both a logRate metric and something like a cpu metric? From what I can observe, this leads to incorrect log rate calculations because it counts the docs from metric indices as well. 🤔

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@simianhacker
Copy link
Member Author

@weltenwort This is ready for a follow up review. I refactored the waffle map endpoint so it will only accept 1 metric instead of multiple.

Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the reduction to a single metric per field. This implementation seems to work in some cases, but not all.

.reduce((prev: InfraMetricInput[], argument: ArgumentNode) => {
return valueFromASTUntyped(argument.value);
}, [])
.pop();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the above reduce return an array even though the metric argument is not an array anymore?

path: info.variableValues.path as InfraPathInput[],
};
}

const { path, metrics }: InfraPathsAndMetricOptions = info.fieldNodes.reduce(parseFieldNodes, {
const { path, metric }: InfraPathsAndMetricOptions = info.fieldNodes.reduce(parseFieldNodes, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code path seems to not work correctly. The following query leads to an exception:

  query WaffleNodesQuery(
    $sourceId: ID!
    $timerange: InfraTimerangeInput!
    $filterQuery: String
    $path: [InfraPathInput!]!
  ) {
    source(id: $sourceId) {
      id
      map(timerange: $timerange, filterQuery: $filterQuery) {
        nodes(path: $path) {
          path {
            value
          }
          metric(metric: {type:cpu}) {
            name
            value
          }
        }
      }
    }
  }

with these variables:

{
  "sourceId": "default",
  "path": [
    {
      "type": "hosts"
    }
  ],
  "timerange": {
    "from": 1539692147700,
    "interval": "5m",
    "to": 1539692747700
  },
  "filterQuery": null
}

It works if you don't inline the metric or path arguments because then the previous condition short-circuits this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to move all the arguments from the sub branches (nodes and metric) to map. This will eliminate the need to parse the info object and fix this endpoint once and for all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like it would loose us most of the graphql advantages such as querying multiple node groups and metrics via aliasing. I think we should discuss this before throwing out the baby with the bathwater.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The advantage is that it simplifies the code base. We don't have any plans to query the GraphQL endpoint with aliases at this point. If we need the ability to do that in the future for some use case then we can put the effort in at that time.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome 👍

@weltenwort
Copy link
Member

(pending green CI, of course 😉)

@elasticmachine
Copy link
Contributor

💔 Build Failed

@simianhacker
Copy link
Member Author

jenkins test this

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@simianhacker simianhacker merged commit 9c0bdc3 into elastic:feature-infra-ui Oct 17, 2018
@simianhacker simianhacker deleted the log-rate-metrics branch April 17, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants