IBM / apiconnect-trawler

API Connect metrics exporter
MIT License
5 stars 10 forks source link

KeyError: 'graphite' raised when graphite key is not in config.yaml #72

Open dxniel7402 opened 1 year ago

dxniel7402 commented 1 year ago

When running the project with a config.yaml file that doesn't include the graphite key, the following error is raised:

Traceback (most recent call last):
  ...
  File "/app/trawler.py", line 55, in __init__
    if self.config['graphite']['enabled']:
KeyError: 'graphite'

This seems to indicate that the graphite key is expected in the config.yaml file, although it's not included in example configurations or documented.

Steps to Reproduce:

  1. Clone the project.
  2. Run the tests: SECRETS=test-assets coverage run --source . -m py.test
  3. Run the application with a config.yaml that doesn't include the graphite key: python3 trawler.py --config deployment/config.yaml

Expected Behavior:

The application should either run without requiring the graphite key or should provide a more descriptive error message if the key is required.

Suggested Solution:

Document the graphite Key: Update the example config.yaml file and documentation to include the graphite key. For example:

# Example configuration file
trawler:
  frequency: 10
  use_kubeconfig: false
logging: 
  level: debug
  filters: trawler:trace
  format: pretty
prometheus:
  port: 63512
  enabled: true
graphite:
  enabled: false
nets:
  datapower:
    enabled: true
    username: admin
    namespace: apic
  manager:
    enabled: true
    username: admin
    namespace: apic
  analytics:
    enabled: true
    namespace: apic
rickymoorhouse commented 1 year ago

This shouldn't be required - will look at how this can be handled better. As yet I'm also unaware of anyone using trawler with graphite

wdrdres3qew5ts21 commented 7 months ago

I'm still encounter the same error as of latest git clone version. @rickymoorhouse

image

Seem like I still need to put "graphite" key into yaml otherwise I will got the error

image
rickymoorhouse commented 7 months ago

Ah looks like I missed a place in the fix - have an additional fix coming