Skip to main content

Implementing Machine Learning Features

1. Understanding ML Capabilities

Capability Description Use Case
Anomaly Detection Detects unusual patterns in time-series data Monitoring system logs for unexpected behavior
Data Frame Analytics Performs statistical analysis on large datasets Identifying trends in user behavior or system metrics
Forecasting Predicts future values based on historical data Anticipating system load or resource usage

2. Creating Anomaly Detection Jobs

Example: Create Anomaly Detection Job

{
  "job_id": "anomaly-detection-job",
  "description": "Detect anomalies in system logs",
  "analysis_config": {
    "detectors": [
      {
        "detector_label": "Log error rate",
        "field_name": "error_count"
      }
    ]
  },
  "data_description": {
    "time_field": "@timestamp"
  }
}

3. Configuring Detectors

Detector Type Parameters Description
Metric field_name, partition_field Monitors numeric fields for anomalies
Categorization category_field, max_categoricals Identifies unusual categories in data
Rare field_name, time_zone Detects rare occurrences of values

4. Setting Bucket Span

Bucket Span Value Time Range Use Case
1m 1 minute Real-time monitoring of logs
5m 5 minutes Balanced performance and accuracy
1h 1 hour High-level trend analysis

5. Using Influencers

Example: Define Influencer Field

{
  "job_id": "influencer-job",
  "analysis_config": {
    "detectors": [
      {
        "detector_label": "Error count",
        "field_name": "error_count"
      }
    ],
    "influencers": [
      "host",
      "user_agent"
    ]
  }
}

6. Viewing Anomaly Results

Workflow: Analyze Anomalies

  1. Open Kibana ML section
  2. Navigate to Anomaly Detection Jobs
  3. Select job and view results in timeline
  4. Filter by anomaly score or influencer

7. Creating Forecasts

Example: Create Forecast

{
  "job_id": "forecast-job",
  "duration": "1d"
}

8. Using Data Frame Analytics

Analytics Type Input Data Output
Statistical Analysis Time-series logs or metrics Summary statistics and trends
Clustering Unlabeled datasets Groupings of similar data points

9. Training Models

Example: Train Model with Data Frame

{
  "job_id": "training-job",
  "data_frame": {
    "source": {
      "index": "logs"
    },
    "analysis": {
      "regression": {
        "dependent_variable": "response_time"
      }
    }
  }
}

10. Evaluating Model Performance

Metric Definition Threshold
Precision True positives / (True positives + False positives) > 0.8
Recall True positives / (True positives + False negatives) > 0.8
F1 Score 2 * (Precision * Recall) / (Precision + Recall) > 0.8

11. Deploying Trained Models

Workflow: Deploy ML Model

  1. Create model definition in Kibana
  2. Upload trained model to Elasticsearch
  3. Assign model to job or analytics
  4. Start job and monitor performance

12. Managing ML Jobs

ML Job Management Tasks

  • Start/Stop Jobs: Control job execution state
  • Delete Jobs: Remove completed or unused jobs
  • Update Configs: Modify job parameters dynamically
  • View Logs: Monitor job status and errors

Was this article helpful?