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

[Elastic-Agent] Enable introspecting configuration #18124

Merged
merged 12 commits into from
May 4, 2020

Conversation

michalpristas
Copy link
Contributor

@michalpristas michalpristas commented Apr 30, 2020

What does this PR do?

This PR adds 3 options to our agents CLI

Option 1 - Introspecting current config

Usage ./elastic-agent inspect
This will print out current configuration either from fleet or from yml.
Sample output:

datasources:
- inputs:
  - streams:
    - dataset: system.cpu
      metricset: cpu
    - dataset: system.memory
      metricset: memory
    - dataset: system.network
      metricset: network
    - dataset: system.filesystem
      metricset: filesystem
    type: system/metrics
  namespace: default
  use_output: default
download:
  install_path: /Users/michalpristas/agent/data/install
  pgpfile: /Users/michalpristas/agent/data/elastic.pgp
  sourceURI: https://artifacts.elastic.co/downloads/beats/
  target_directory: /Users/michalpristas/agent/data/downloads
  timeout: 30s
...

Option 2 - Introspecting used outputs

Usage ./elastic-agent inspect output
This will print out outputs which are actually used . If config contains definition for output but output is not used in any datastream it will not be present in the printout
Sample output:

default
monitoring

Option 3: Introspecting specific output

Usage: ./elastic-agent inspect output -o default
This will print out actual configuration of the beats, this helps you understand how configuration retrieved from fleet translates to configuration which is sent out to the process itself.
Sample output:

[default] metricbeat:
metricbeat:
  modules:
  - index: metrics-system.filesystem-default
    metricsets:
    - filesystem
    module: system
    processors:
    - add_fields:
        fields:
          dataset: system.filesystem
          namespace: default
          type: metrics
        target: stream
output:
  elasticsearch:
    hosts:
    - 127.0.0.1:9200
    password: changeme
    username: elastic

Why is it important?

To improve debugging experience

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

@michalpristas michalpristas added enhancement Project:fleet Ingest Management:beta1 Group issues for ingest management beta1 labels Apr 30, 2020
@michalpristas michalpristas self-assigned this Apr 30, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/ingest-management (Team:Ingest Management)

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Apr 30, 2020
@michalpristas michalpristas added needs_backport PR is waiting to be backported to other branches. and removed needs_team Indicates that the issue/PR needs a Team:* label labels Apr 30, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented Apr 30, 2020

💚 Build Succeeded

Pipeline View Test View Changes Artifacts preview stats

Expand to view the summary

Build stats

@michalpristas michalpristas added Ingest Management:alpha1 Group issues for ingest management alpha1 and removed Ingest Management:beta1 Group issues for ingest management beta1 labels Apr 30, 2020
@ruflin
Copy link
Contributor

ruflin commented Apr 30, 2020

I'm used to docker image inspect ...

}, nil
}

// Execute tries to enroll the agent into Fleet.
Copy link
Contributor

Choose a reason for hiding this comment

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

You are sure the comment matches the behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh my copy cat

@ruflin
Copy link
Contributor

ruflin commented Apr 30, 2020

I'm confused by your Option 3: You select an output and get the metricbeat config for it

@michalpristas
Copy link
Contributor Author

you select the output and you get configuration for all beats writing to that specific output

@ruflin
Copy link
Contributor

ruflin commented Apr 30, 2020

@michalpristas I wonder if that would be the way someone thinks of trying to find what goes wrong during debugging. But lets iterate later on naming and order of params and get this in.

@michalpristas
Copy link
Contributor Author

i'm open to suggestions,i'm biased by how agent deal with streams

Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

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

I think this would effectively help integrations team to move forward with debugging, let's fix the issue concerning the -c we can do a follow for my suggestion of been able to export them.

Args: cobra.ExactArgs(0),
Run: func(c *cobra.Command, args []string) {
command, err := application.NewIntrospectConfigCmd("elastic-agent.yml")
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a problem here, if you use -c to specify another configuration we will still load the default and not the one specified.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

solved

cmd.Flags().StringP("program", "p", "", "type of program to introspect, needs to be combined with output. e.g filebeat")

return cmd
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Two things, I've played with the command locally. When you run the "output" subcommand you have only the list of the outputs. Maybe we could have a better default like displaying all the configuration that we have for all the defined outputs?

Maybe we could add a flag that will output to disk all the configurations and grouped output, Maybe -disk, its hard to find a good name because that behavior is often associated to -o (output).

/default/
 filebeat.yml
 metricbeat.yml

The above would allow anyone to test the configuration outside of the agent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can we do this in a follwup? let's get this in for 7.8 and we can work on naming and use cases in a separate issue. nicolas had also some comments about the form of the command

Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

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

LGTM get some debug in place.

@michalpristas michalpristas merged commit 1c2e4b9 into elastic:master May 4, 2020
michalpristas added a commit to michalpristas/beats that referenced this pull request May 4, 2020
* introspection

* changelog

* mage fmt

* introspect -> inspect

* follow -c argument

* conflicts
michalpristas added a commit to michalpristas/beats that referenced this pull request May 4, 2020
* introspection

* changelog

* mage fmt

* introspect -> inspect

* follow -c argument

* conflicts
michalpristas added a commit that referenced this pull request May 4, 2020
* introspection

* changelog

* mage fmt

* introspect -> inspect

* follow -c argument

* conflicts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Ingest Management:alpha1 Group issues for ingest management alpha1 needs_backport PR is waiting to be backported to other branches. review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants