K-Phoen / backstage-plugin-grafana

Grafana plugin for Backstage
Apache License 2.0
57 stars 33 forks source link

Support for multihost and status for alerts #76

Open Vity01 opened 1 year ago

Vity01 commented 1 year ago

I present my solution for multihost Grafanas. It's easy to use and the code should be backwards compatible with current implementation. Use can choose whether to use multihost setting or a simple one.

Example of usage:

# app-config.yaml
proxy:
  '/grafana/api':
    # Maybe a public or an internal DNS
    target: https://grafana.host/
    headers:
      Authorization: Bearer ${GRAFANA_TOKEN}
  '/grafana2/api':
    # Maybe a public or an internal DNS
    target: https://grafana2.host/
    headers:
      Authorization: Bearer ${GRAFANA2_TOKEN}

grafana:
  hosts:                
    - id: 'default' #unique host identifier used in Catalog Yaml annotation `grafana/source-id`

      # Publicly accessible domain
      domain: https://monitoring.company.com

      # Path to use for requests via the proxy, defaults to /grafana/api        
      proxyPath: '/grafana/api'

      # Is unified alerting enabled in Grafana?
      # See: https://grafana.com/blog/2021/06/14/the-new-unified-alerting-system-for-grafana-everything-you-need-to-know/
      # Optional. Default: false
      unifiedAlerting: false

    - id: 'my-second-instance' #unique host identifier used in Catalog Yaml annotation `grafana/source-id`     

      # Publicly accessible domain
      domain: https://monitoring2.company.com 

      # Path to use for requests via the proxy, defaults to /grafana/api        
      proxyPath: '/grafana2/api'      

      # Is unified alerting enabled in Grafana?
      # See: https://grafana.com/blog/2021/06/14/the-new-unified-alerting-system-for-grafana-everything-you-need-to-know/
      # Optional. Default: false
      unifiedAlerting: false

I also integrated support for getting status for Alerts (sorry I had to mix it, it would be a mess to separate it). https://github.com/K-Phoen/backstage-plugin-grafana/pull/65 and https://github.com/K-Phoen/backstage-plugin-grafana/pull/70

dtemir commented 1 year ago

@Vity01 This is great. Do you have any advice on how this can be approached without manually defining Grafanas in app-config.yaml? We want to allow developers bring their own Grafanas to Backstage with Resource kind

Vity01 commented 1 year ago

@dtemir I don't think it is a good idea. Think about secrets, proxies...

higor-duarte-oliveira commented 8 months ago

@Vity01 Any updates on this PR?