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

[ML] Datafeed overrides generating incorrect datafeed config #78846

Closed
phillipb opened this issue Sep 29, 2020 · 1 comment · Fixed by #78925
Closed

[ML] Datafeed overrides generating incorrect datafeed config #78846

phillipb opened this issue Sep 29, 2020 · 1 comment · Fixed by #78925
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Anomaly Detection ML anomaly detection :ml NeededFor:ML v7.10.0

Comments

@phillipb
Copy link
Contributor

When trying to override the aggregation for a datafeed via /api/ml/modules/setup, the setup api generates an invalid aggregation. It appears that the default aggregation is merged with the override instead of being overridden which results in an invalid aggregation. I would expect that the aggregation would be completely overridden, not merged.

Here's an example override for the metrics_ui_hosts module:

{
  "job_id": "hosts_network_in",
  "indices": [
    "INDEX_PATTERN_NAME"
  ],
  "indices_options": {
    "allow_no_indices": true
  },
  "query": {
    "bool": {
      "must": [
        {
          "exists": {
            "field": "system.network"
          }
        }
      ]
    }
  },
  "chunking_config": {
    "mode": "manual",
    "time_span": "900s"
  },
  "aggregations": {
    "cloud.project.id": {
      "terms": {
        "field": "cloud.project.id"
      },
      "aggregations": {
        "host.name": {
          "terms": {
            "field": "host.name",
            "size": 100
          },
          "aggregations": {
            "buckets": {
              "date_histogram": {
                "field": "@timestamp",
                "fixed_interval": "5m"
              },
              "aggregations": {
                "@timestamp": {
                  "max": {
                    "field": "@timestamp"
                  }
                },
                "bytes_in_max": {
                  "max": {
                    "field": "system.network.in.bytes"
                  }
                },
                "bytes_in_derivative": {
                  "derivative": {
                    "buckets_path": "bytes_in_max"
                  }
                },
                "positive_only": {
                  "bucket_script": {
                    "buckets_path": {
                      "in_derivative": "bytes_in_derivative.value"
                    },
                    "script": "params.in_derivative > 0.0 ? params.in_derivative : 0.0"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
} 

Here's what the setup api tries to save to the datafeed:

{
    "id": "datafeed-kibana-metrics-ui-default-default-hosts_network_in",
    "config": {
      "job_id": "kibana-metrics-ui-default-default-hosts_network_in",
      "indices": [
        "metricbeat-*"
      ],
      "indices_options": {
        "allow_no_indices": true
      },
      "query": {
        "bool": {
          "must": [
            {
              "exists": {
                "field": "system.network"
              }
            }
          ]
        }
      },
      "chunking_config": {
        "mode": "manual",
        "time_span": "900s"
      },
      "aggregations": {
        "host.name": {
          "terms": {
            "field": "host.name",
            "size": 100
          },
          "aggregations": {
            "buckets": {
              "date_histogram": {
                "field": "@timestamp",
                "fixed_interval": "5m"
              },
              "aggregations": {
                "@timestamp": {
                  "max": {
                    "field": "@timestamp"
                  }
                },
                "bytes_in_max": {
                  "max": {
                    "field": "system.network.in.bytes"
                  }
                },
                "bytes_in_derivative": {
                  "derivative": {
                    "buckets_path": "bytes_in_max"
                  }
                },
                "positive_only": {
                  "bucket_script": {
                    "buckets_path": {
                      "in_derivative": "bytes_in_derivative.value"
                    },
                    "script": "params.in_derivative > 0.0 ? params.in_derivative : 0.0"
                  }
                }
              }
            }
          }
        },
        "cloud.project.id": {
          "terms": {
            "field": "cloud.project.id"
          },
          "aggregations": {
            "host.name": {
              "terms": {
                "field": "host.name",
                "size": 100
              },
              "aggregations": {
                "buckets": {
                  "date_histogram": {
                    "field": "@timestamp",
                    "fixed_interval": "5m"
                  },
                  "aggregations": {
                    "@timestamp": {
                      "max": {
                        "field": "@timestamp"
                      }
                    },
                    "bytes_in_max": {
                      "max": {
                        "field": "system.network.in.bytes"
                      }
                    },
                    "bytes_in_derivative": {
                      "derivative": {
                        "buckets_path": "bytes_in_max"
                      }
                    },
                    "positive_only": {
                      "bucket_script": {
                        "buckets_path": {
                          "in_derivative": "bytes_in_derivative.value"
                        },
                        "script": "params.in_derivative > 0.0 ? params.in_derivative : 0.0"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }

As you can see the aggregations section has merged the default aggregation with the override resulting in an invalid aggregation.

@phillipb phillipb added bug Fixes for quality problems that affect the customer experience :ml v7.10.0 labels Sep 29, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@jgowdyelastic jgowdyelastic changed the title Datafeed overrides generating incorrect datafeed config [ML] Datafeed overrides generating incorrect datafeed config Sep 29, 2020
@jgowdyelastic jgowdyelastic self-assigned this Sep 29, 2020
@peteharverson peteharverson added the Feature:Anomaly Detection ML anomaly detection label Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Anomaly Detection ML anomaly detection :ml NeededFor:ML v7.10.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants