- 
                Notifications
    You must be signed in to change notification settings 
- Fork 508
[Draft] Add docker_otel_input package #15739
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
          
     Open
      
      
            strawgate
  wants to merge
  4
  commits into
  elastic:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
strawgate:docker_otel_input
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
      
        
          +343
        
        
          −0
        
        
          
        
      
    
  
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            4 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| Elastic License 2.0 | ||
|  | ||
| URL: https://www.elastic.co/licensing/elastic-license | ||
|  | ||
| ## Acceptance | ||
|  | ||
| By using the software, you agree to all of the terms and conditions below. | ||
|  | ||
| ## Copyright License | ||
|  | ||
| The licensor grants you a non-exclusive, royalty-free, worldwide, | ||
| non-sublicensable, non-transferable license to use, copy, distribute, make | ||
| available, and prepare derivative works of the software, in each case subject to | ||
| the limitations and conditions below. | ||
|  | ||
| ## Limitations | ||
|  | ||
| You may not provide the software to third parties as a hosted or managed | ||
| service, where the service provides users with access to any substantial set of | ||
| the features or functionality of the software. | ||
|  | ||
| You may not move, change, disable, or circumvent the license key functionality | ||
| in the software, and you may not remove or obscure any functionality in the | ||
| software that is protected by the license key. | ||
|  | ||
| You may not alter, remove, or obscure any licensing, copyright, or other notices | ||
| of the licensor in the software. Any use of the licensor's trademarks is subject | ||
| to applicable law. | ||
|  | ||
| ## Patents | ||
|  | ||
| The licensor grants you a license, under any patent claims the licensor can | ||
| license, or becomes able to license, to make, have made, use, sell, offer for | ||
| sale, import and have imported the software, in each case subject to the | ||
| limitations and conditions in this license. This license does not cover any | ||
| patent claims that you cause to be infringed by modifications or additions to | ||
| the software. If you or your company make any written claim that the software | ||
| infringes or contributes to infringement of any patent, your patent license for | ||
| the software granted under these terms ends immediately. If your company makes | ||
| such a claim, your patent license ends immediately for work on behalf of your | ||
| company. | ||
|  | ||
| ## Notices | ||
|  | ||
| You must ensure that anyone who gets a copy of any part of the software from you | ||
| also gets a copy of these terms. | ||
|  | ||
| If you modify the software, you must include in any modified copies of the | ||
| software prominent notices stating that you have modified the software. | ||
|  | ||
| ## No Other Rights | ||
|  | ||
| These terms do not imply any licenses other than those expressly granted in | ||
| these terms. | ||
|  | ||
| ## Termination | ||
|  | ||
| If you use the software in violation of these terms, such use is not licensed, | ||
| and your licenses will automatically terminate. If the licensor provides you | ||
| with a notice of your violation, and you cease all violation of this license no | ||
| later than 30 days after you receive that notice, your licenses will be | ||
| reinstated retroactively. However, if you violate these terms after such | ||
| reinstatement, any additional violation of these terms will cause your licenses | ||
| to terminate automatically and permanently. | ||
|  | ||
| ## No Liability | ||
|  | ||
| *As far as the law allows, the software comes as is, without any warranty or | ||
| condition, and the licensor will not be liable to you for any damages arising | ||
| out of these terms or the use or nature of the software, under any kind of | ||
| legal claim.* | ||
|  | ||
| ## Definitions | ||
|  | ||
| The **licensor** is the entity offering these terms, and the **software** is the | ||
| software the licensor makes available under these terms, including any portion | ||
| of it. | ||
|  | ||
| **you** refers to the individual or entity agreeing to these terms. | ||
|  | ||
| **your company** is any legal entity, sole proprietorship, or other kind of | ||
| organization that you work for, plus all organizations that have control over, | ||
| are under the control of, or are under common control with that | ||
| organization. **control** means ownership of substantially all the assets of an | ||
| entity, or the power to direct its management and policies by vote, contract, or | ||
| otherwise. Control can be direct or indirect. | ||
|  | ||
| **your licenses** are all the licenses granted to you for the software under | ||
| these terms. | ||
|  | ||
| **use** means anything you do with the software requiring one of your licenses. | ||
|  | ||
| **trademark** means trademarks, service marks, and similar rights. | 
        
          
  
    
      
          
            3 changes: 3 additions & 0 deletions
          
          3 
        
  packages/docker_otel_input/_dev/test/policy/test-docker-stats.yml
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| vars: | ||
| period: "10s" | ||
| endpoint: "unix:///var/run/docker.sock" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| receivers: | ||
| docker_stats: | ||
| {{#if period}} | ||
| collection_interval: {{period}} | ||
| {{else}} | ||
| collection_interval: 60s | ||
| {{/if}} | ||
| {{#if endpoint}} | ||
| endpoint: {{endpoint}} | ||
| {{/if}} | ||
| {{#if excluded_images}} | ||
| excluded_images: | ||
| {{#each excluded_images as |image|}} | ||
| - {{image}} | ||
| {{/each}} | ||
| {{/if}} | ||
| {{#if timeout}} | ||
| timeout: {{timeout}} | ||
| {{/if}} | ||
| {{#if api_version}} | ||
| api_version: "{{api_version}}" | ||
| {{/if}} | ||
| {{#if provide_per_core_cpu_metrics}} | ||
| provide_per_core_cpu_metrics: {{provide_per_core_cpu_metrics}} | ||
| {{/if}} | ||
| {{#if container_labels_to_metric_labels}} | ||
| container_labels_to_metric_labels: | ||
| {{container_labels_to_metric_labels}} | ||
| {{/if}} | ||
| {{#if env_vars_to_metric_labels}} | ||
| env_vars_to_metric_labels: | ||
| {{env_vars_to_metric_labels}} | ||
| {{/if}} | ||
|  | ||
| processors: | ||
| resourcedetection: | ||
| # Modify the list of detectors to match the cloud environment | ||
| detectors: [env, system, gcp, ec2, azure] | ||
| timeout: 2s | ||
| override: false | ||
|  | ||
| service: | ||
| pipelines: | ||
| metrics: | ||
| receivers: | ||
| - docker_stats | ||
| processors: | ||
| - resourcedetection | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| - version: "0.2.0" | ||
| changes: | ||
| - description: Initial draft of Docker Stats OpenTelemetry input package | ||
| type: enhancement | ||
| link: https://github.com/elastic/integrations/pull/15739 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| # Docker Container Stats (OpenTelemetry) | ||
|  | ||
| This integration collects Docker container metrics using the OpenTelemetry Collector's [dockerstats receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/dockerstatsreceiver). | ||
|  | ||
| ## Overview | ||
|  | ||
| Docker Container Stats are collected via the `docker_stats` receiver. It collects container metrics from the Docker daemon using the Docker Stats API. It provides comprehensive metrics about container resource usage including CPU, memory, network, and block I/O statistics. | ||
|  | ||
| ## Requirements | ||
|  | ||
| - Docker API version 1.25 or higher | ||
| - Access to the Docker daemon socket (default: `unix:///var/run/docker.sock` on linux and `npipe:////./pipe/docker_engine` on Windows) | ||
|  | ||
| ## Compatibility | ||
|  | ||
| This integration uses the OpenTelemetry dockerstats receiver which is currently in **alpha** stability. The configuration and metrics may change between versions. | ||
|  | ||
| ## Metrics | ||
|  | ||
| This integration collects the following types of metrics: | ||
|  | ||
| ### CPU Metrics | ||
|  | ||
| - Total CPU usage (nanoseconds) | ||
| - Kernel mode CPU usage (nanoseconds) | ||
| - User mode CPU usage (nanoseconds) | ||
| - CPU limit | ||
|  | ||
| ### Memory Metrics | ||
|  | ||
| - Memory usage (bytes) | ||
| - Memory limit (bytes) | ||
| - Memory cache (bytes) | ||
| - Memory RSS (bytes) | ||
|  | ||
| ### Network Metrics | ||
|  | ||
| - Bytes received/transmitted | ||
| - Packets received/transmitted | ||
| - Receive/transmit errors | ||
| - Receive/transmit dropped packets | ||
|  | ||
| ### Block I/O Metrics | ||
|  | ||
| - Bytes read/written | ||
| - Read/write operations | ||
|  | ||
| ### Metadata | ||
|  | ||
| - Container ID | ||
| - Container name | ||
| - Image name | ||
| - Container runtime | ||
|  | ||
| ## Advanced Configuration | ||
|  | ||
| ### Docker Endpoint | ||
|  | ||
| The endpoint of the Docker daemon. Default is `unix:///var/run/docker.sock`. | ||
|  | ||
| For remote Docker hosts, you can use TCP endpoints like `tcp://docker-host:2375`. | ||
|  | ||
| ### Excluded Images | ||
|  | ||
| A list of container image names to exclude from metrics collection. Supports wildcards. | ||
|  | ||
| Example: | ||
| ``` | ||
| - "nginx:*" | ||
| - "redis:latest" | ||
| ``` | ||
|  | ||
| ### API Version | ||
|  | ||
| The Docker API version to use. Default is `1.25` (the minimum supported version). | ||
|  | ||
| ### Per-Core CPU Metrics | ||
|  | ||
| When enabled, provides CPU metrics broken down by individual CPU cores. Default is `false`. | ||
|  | ||
| **Note:** Enabling this option can significantly increase the number of metrics collected. | ||
|  | ||
| ### Container Labels to Metric Labels | ||
|  | ||
| Map container labels to metric resource attributes. This allows you to add custom dimensions to your metrics based on container labels. | ||
|  | ||
| Example YAML format: | ||
| ```yaml | ||
| my.container.label: my_metric_label | ||
| app.version: version | ||
| ``` | ||
|  | ||
| ### Environment Variables to Metric Labels | ||
|  | ||
| Map container environment variables to metric resource attributes. | ||
|  | ||
| Example YAML format: | ||
| ```yaml | ||
| MY_ENV_VAR: my_metric_label | ||
| APP_VERSION: version | ||
| ``` | ||
|  | ||
| ## Additional Resources | ||
|  | ||
| - [OpenTelemetry dockerstats receiver documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/dockerstatsreceiver) | ||
| - [Docker Stats API documentation](https://docs.docker.com/engine/api/v1.43/#tag/Container/operation/ContainerStats) | ||
| - [Elastic Observability documentation](https://www.elastic.co/guide/en/observability/current/index.html) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| - name: data_stream.type | ||
|         
                  strawgate marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| type: constant_keyword | ||
| description: Data stream type. | ||
| - name: data_stream.dataset | ||
| type: constant_keyword | ||
| description: Data stream dataset. | ||
| - name: data_stream.namespace | ||
| type: constant_keyword | ||
| description: Data stream namespace. | ||
| - name: '@timestamp' | ||
| type: date | ||
| description: Event timestamp. | ||
      
      Loading
      
  Sorry, something went wrong. Reload?
      Sorry, we cannot display this file.
      Sorry, this file is invalid so it cannot be displayed.
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,74 @@ | ||||||
| format_version: 3.5.0 | ||||||
| name: docker_otel_input | ||||||
| title: "Docker (OpenTelemetry)" | ||||||
| version: 0.2.0 | ||||||
| description: "Collect Docker container metrics using OpenTelemetry Collector" | ||||||
| type: input | ||||||
| categories: | ||||||
| - containers | ||||||
| - monitoring | ||||||
| - observability | ||||||
| - opentelemetry | ||||||
| conditions: | ||||||
| kibana: | ||||||
| version: "^9.2.0" | ||||||
| elastic: | ||||||
| subscription: "basic" | ||||||
| icons: | ||||||
| - src: /img/docker_logo.svg | ||||||
| title: Sample logo | ||||||
| size: 32x32 | ||||||
| type: image/svg+xml | ||||||
| policy_templates: | ||||||
| - name: docker_stats | ||||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be the name of the receiver, as this is used by Fleet as default dataset. In this case it will likely be  We will prepare automatic validation for this in elastic/elastic-package#2974 
        Suggested change
       
 | ||||||
| title: Docker Stats | ||||||
| description: Collect Docker container performance metrics including CPU, memory, network, and block I/O | ||||||
| input: otelcol | ||||||
| type: metrics | ||||||
| template_path: input.yml.hbs | ||||||
| vars: | ||||||
| - name: period | ||||||
| type: text | ||||||
| title: Collection Interval | ||||||
| description: How often to collect metrics (e.g., 10s, 1m). Default is 60s. | ||||||
| required: true | ||||||
| - name: endpoint | ||||||
| type: text | ||||||
| title: Docker Endpoint | ||||||
| description: Docker daemon endpoint | ||||||
| required: false | ||||||
| - name: excluded_images | ||||||
| type: text | ||||||
| title: Excluded Images | ||||||
| description: List of image names to exclude from metrics collection | ||||||
| multi: true | ||||||
| required: false | ||||||
| - name: timeout | ||||||
| type: text | ||||||
| title: Timeout | ||||||
| description: Timeout for Docker API requests | ||||||
| required: false | ||||||
| - name: api_version | ||||||
| type: text | ||||||
| title: API Version | ||||||
| description: Docker API version to use | ||||||
| required: false | ||||||
| - name: provide_per_core_cpu_metrics | ||||||
| type: bool | ||||||
| title: Provide Per-Core CPU Metrics | ||||||
| description: Enable per-core CPU metrics collection | ||||||
| default: false | ||||||
| required: false | ||||||
| - name: container_labels_to_metric_labels | ||||||
| type: yaml | ||||||
| title: Container Labels to Metric Labels | ||||||
| description: Mapping of container labels to metric labels (YAML format) | ||||||
| required: false | ||||||
| - name: env_vars_to_metric_labels | ||||||
| type: yaml | ||||||
| title: Environment Variables to Metric Labels | ||||||
| description: Mapping of environment variables to metric labels (YAML format) | ||||||
| required: false | ||||||
| owner: | ||||||
| github: elastic/obs-infraobs-integrations | ||||||
| type: elastic | ||||||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be configurable as long as it lives here. In the long term this neeeds to not be in each package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could inject this from Fleet, and make it configurable there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually need to be configurable for now?