salt icon indicating copy to clipboard operation
salt copied to clipboard

State module SALT.STATES.GRAFANA doesn't work

Open maxlim0 opened this issue 8 years ago • 3 comments

Description of Issue/Question

Here is issue with https://docs.saltstack.com/en/latest/ref/states/all/salt.states.grafana.html#module-salt.states.grafana

salt 'salt.net' state.sls grafana-dashboards
salt.net:
----------
          ID: Ensure myservice dashboard is managed
    Function: grafana.dashboard_present
        Name: myservice
      Result: False
     Comment: State 'grafana.dashboard_present' was not found in SLS 'grafana-dashboards'
              Reason: 'grafana' __virtual__ returned False
     Changes:

Summary for salt.net
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:   0.000 ms

I thinks cause of issue this code in https://github.com/saltstack/salt/blob/develop/salt/states/grafana.py#L182 :

def __virtual__():
    '''
    Only load if grafana is available.
    '''
    return 'grafana' if 'elasticsearch.exists' in __salt__ else False

Documentations says as: "Since virtual is called before the module is loaded, salt will be unreliable as not all modules will be available at this point in time."

pip list | grep elasticsearch
elasticsearch (6.2.0)

Setup

states/grafana-dashboards/init.sls

  Ensure myservice dashboard is managed:
      grafana.dashboard_present:
        - name: myservice
        - dashboard:
            annotations:
              enable: true
              list: []
            editable: true
            hideAllLegends: false
            hideControls: false
            nav:
              - collapse: false
                enable: true
                notice: false
                now: true
                refresh_intervals:
                  - 10s
                  - 30s
                  - 1m
                  - 5m
                  - 15m
                  - 30m
                  - 1h
                  - 2h
                  - 1d
                status: Stable
        - rows:
            - collapse: false
              editable: true
              height: 150px
              title: System Health
              panels:
                - aliasColors: {}
                  id: 200000
                  annotate:
                    enable: false
                  bars: false
                  datasource: null
                  editable: true
                  error: false
                  fill: 7
                  grid:
                    leftMax: 100
                    leftMin: null
                    rightMax: null
                    rightMin: null
                    threshold1: 60
                    threshold1Color: rgb(216, 27, 27)
        - profile:
            hosts:
              - es1.example.com:9200
              - es2.example.com:9200
            index: grafana-dash

Versions Report

salt --versions-report
Salt Version:
           Salt: 2018.3.0

Dependency Versions:
           cffi: Not Installed
       cherrypy: 3.5.0
       dateutil: 2.2
      docker-py: Not Installed
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
         Jinja2: 2.9.4
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.2
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.9 (default, Jun 29 2016, 13:08:31)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.4.0
           RAET: Not Installed
          smmap: 0.8.2
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: debian 8.10
         locale: ANSI_X3.4-1968
        machine: x86_64
        release: 3.16.0-4-amd64
         system: Linux
        version: debian 8.10

salt-master --version salt-master 2018.3.0 (Oxygen) salt-minion --version salt-minion 2018.3.0 (Oxygen)

maxlim0 avatar Apr 05 '18 13:04 maxlim0

@maxsolyaris Thanks for the report. The __virtual__ function is checking to make sure that the elasticsearch Salt module is available and it appears that something is causing it not to be. On the machine in question can you, from a Python shell, attempt to run the following imports.

    import elasticsearch
    from elasticsearch import RequestsHttpConnection

And see if they both run successfully.

garethgreenaway avatar Apr 05 '18 20:04 garethgreenaway

Both of this imports work pretty fine without any errors.

maxlim0 avatar Apr 05 '18 20:04 maxlim0

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

stale[bot] avatar Jul 19 '19 20:07 stale[bot]