Skip to content

Only output config parameters that differ from the defaults for /config endpoint #3645

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

Conversation

simonswine
Copy link
Contributor

What this PR does:

This changes the behaviour of the config endpoint to only show the config values that have really changed towards the default config.

I personally get lost quite often in the very verbose output of the user's configuration that includes the defaults. This tries to solve that by only show values that differ from the defaults.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Gather feedback if this is something useful
  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@simonswine
Copy link
Contributor Author

This is the example output for using docs/configuration/single-process-config-blocks.yaml

auth_enabled: false
blocks_storage:
  backend: filesystem
  bucket_store:
    sync_dir: /tmp/cortex/tsdb-sync
  filesystem:
    dir: ./data/tsdb
  tsdb:
    dir: /tmp/cortex/tsdb
compactor:
  data_dir: /tmp/cortex/compactor
  sharding_ring:
    kvstore:
      store: inmemory
distributor:
  shard_by_all_labels: true
frontend_worker:
  match_max_concurrent: true
ingester:
  lifecycler:
    address: 127.0.0.1
    final_sleep: 0s
    min_ready_duration: 0s
    num_tokens: 512
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
ingester_client:
  grpc_client_config:
    grpc_compression: gzip
    max_send_msg_size: 104857600
ruler:
  enable_api: true
  storage:
    local:
      directory: /tmp/cortex/rules
    type: local
server:
  grpc_server_max_concurrent_streams: 1000
  grpc_server_max_recv_msg_size: 104857600
  grpc_server_max_send_msg_size: 104857600
  http_listen_port: 9009
storage:
  engine: blocks

@pracucci
Copy link
Contributor

pracucci commented Jan 5, 2021

@simonswine I see a value in this change, but what do you think about enabling this logic via a query string parameter passed to the /config endpoint? This way we would preserve the current behaviour while adding support to the diff only.

@simonswine simonswine force-pushed the 20210105_show_only_config_diff_towards_default branch 2 times, most recently from 9e55df7 to 55662d5 Compare January 6, 2021 11:20
@simonswine simonswine force-pushed the 20210105_show_only_config_diff_towards_default branch from 55662d5 to 24cef90 Compare January 6, 2021 12:45
@simonswine simonswine changed the title WIP: Only output config parameters that differ from the defaults for /config endpoint Only output config parameters that differ from the defaults for /config endpoint Jan 6, 2021
@simonswine simonswine marked this pull request as ready for review January 6, 2021 12:48
Copy link
Contributor

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

LGTM, thank you! This is very useful!

This adds a `mode` query parameter for the config endpoint:

- `/config?mode=diff`: Shows the YAML configuration with all values that
differ from the defaults.

- `/config?mode=defaults`: Shows the YAML configuration with all the
default values.

Signed-off-by: Christian Simon <simon@swine.de>
@simonswine simonswine force-pushed the 20210105_show_only_config_diff_towards_default branch from 24cef90 to cf080b9 Compare January 6, 2021 17:59
Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

I love it, well done! 👏

Comment on lines +86 to +87
defaultFS := flag.NewFlagSet("", flag.PanicOnError)
defaultConfig.RegisterFlags(defaultFS)
Copy link
Contributor

Choose a reason for hiding this comment

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

[non blocking, just FYI] You can achieve the same with flagext.DefaultValues().

@pracucci pracucci merged commit 2dd7692 into cortexproject:master Jan 8, 2021
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