%PDF- %PDF-
Direktori : /lib/python2.7/site-packages/salt/states/ |
Current File : //lib/python2.7/site-packages/salt/states/grafana.pyo |
� ���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l Z d d l m Z d d l m Z d d l m Z d � Z d � Z d � Z d d d d d d � Z d d d � Z d S( uC Manage Grafana Dashboards This module uses ``elasticsearch``, which can be installed via package, or pip. You can specify elasticsearch hosts directly to the module, or you can use an elasticsearch profile via pillars: .. code-block:: yaml mygrafanaprofile: hosts: - es1.example.com:9200 - es2.example.com:9200 index: grafana-dash .. code-block:: yaml # Basic usage (uses default pillar profile key 'grafana') Ensure myservice dashboard is managed: grafana.dashboard_present: - name: myservice - dashboard_from_pillar: default - rows_from_pillar: - systemhealth - requests # Passing hosts in Ensure myservice dashboard is managed: grafana.dashboard_present: - name: myservice - dashboard_from_pillar: default - 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) threshold2: null threshold2Color: rgba(234, 112, 112, 0.22) leftYAxisLabel: '' legend: avg: false current: false max: false min: false show: false total: false values: false lines: true linewidth: 1 nullPointMode: connected percentage: false pointradius: 5 points: false renderer: flot resolution: 100 scale: 1 seriesOverrides: [] span: 4 stack: false steppedLine: false targets: - target: cloudwatch.aws.ec2.mysrv.cpuutilization.average title: CPU (asg average) tooltip: query_as_alias: true shared: false value_type: cumulative type: graph x-axis: true y-axis: true y_formats: - short - short zerofill: true - rows_from_pillar: - systemhealth - requests - profile: hosts: - es1.example.com:9200 - es2.example.com:9200 index: grafana-dash # Using a profile from pillars 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 time_options: - 5m - 15m - 1h - 2h - 3h - 4h - 6h - 12h - 1d - 2d - 4d - 7d - 16d - 30d type: timepicker originalTitle: dockerregistry refresh: 1m rows: [] sharedCrosshair: false style: dark tags: [] templating: enable: true list: [] time: from: now-2h to: now timezone: browser - rows_from_pillars: - systemhealth - requests - profile: mygrafanaprofile The behavior of this module is to create dashboards if they do not exist, to add rows if they do not exist in existing dashboards, and to update rows if they exist in dashboards. The module will not manage rows that are not defined, allowing users to manage their own custom rows. i ( t absolute_importt print_functiont unicode_literalsN( t SaltInvocationError( t DictDiffer( t string_typesc C@ s d t k r d St S( u, Only load if grafana is available. u elasticsearch.existsu grafana( t __salt__t False( ( ( s7 /usr/lib/python2.7/site-packages/salt/states/grafana.pyt __virtual__� s c C@ st t | t � rF t d | � } | sL d j | � } t | � � qL n | } | j d � } | j d � } | | f S( uI From a pillar key, or a dictionary, return index and host keys. u config.optionu% Pillar key for profile {0} not found.u hostsu index( t isinstanceR R t formatR t get( t profilet _profilet msgt hostst index( ( s7 /usr/lib/python2.7/site-packages/salt/states/grafana.pyt _parse_profile� s c C@ s� t j | � } t j | � } x( | d D] } d | k r) | d =q) q) Wx( | d D] } d | k rT | d =qT qT Wt | | � } | j � p� | j � p� | j � S( u8 Check if grafana dashboard row and _row differ u panelsu id( t copyt deepcopyR t changedt addedt removed( t rowt _rowt row_copyt _row_copyt panelt _panelt diff( ( s7 /usr/lib/python2.7/site-packages/salt/states/grafana.pyt _rows_differ� s u grafanac C@ s� i | d 6d( d 6d d 6i d 6} | s7 t d � � n | rR | rR t d � � n t | � \ } } | sy t d � � n | s� t d | � } n | s� g } n | rx^ | D]S } t d | � } t | t � r� x+ | D] } | j | � q� Wq� | j | � q� Wn t d d | d | d d d | � } | r�t d d | d | d d d | � } | j d i � j d � } t j j j | � } nF | s�t d � � n t d r�d j | � | d <d( | d <| S| } g } g } i } xp t | d � D]^ \ } } x2 | d D]&