def returner(ret):
    '''
    Return data to a influxdb data store
    '''
    serv = _get_serv(ret)

    # strip the 'return' key to avoid data duplication in the database
    json_return = salt.utils.json.dumps(ret['return'])
    del ret['return']
    json_full_ret = salt.utils.json.dumps(ret)

    # create legacy request in case an InfluxDB 0.8.x version is used
    if "influxdb08" in serv.__module__:
        req = [
            {
                'name': 'returns',
                'columns': ['fun', 'id', 'jid', 'return', 'full_ret'],
                'points': [
                    [ret['fun'], ret['id'], ret['jid'], json_return, json_full_ret]
                ],
            }
        ]
    # create InfluxDB 0.9+ version request
    else:
        req = [
            {
                'measurement': 'returns',
                'tags': {
                    'fun': ret['fun'],
                    'id': ret['id'],
                    'jid': ret['jid']
                },
                'fields': {
                    'return': json_return,
                    'full_ret': json_full_ret
                }
            }
        ]

    try:
        serv.write_points(req)
    except Exception as ex:
        log.critical('Failed to store return with InfluxDB returner: %s', ex)
def returner ( ret ) : serv = _get_serv ( ret ) json_return = salt . utils . json . dumps ( ret [ 'return' ] ) del ret [ 'return' ] json_full_ret = salt . utils . json . dumps ( ret ) if "influxdb08" in serv . __module__ : req = [ { 'name' : 'returns' , 'columns' : [ 'fun' , 'id' , 'jid' , 'return' , 'full_ret' ] , 'points' : [ [ ret [ 'fun' ] , ret [ 'id' ] , ret [ 'jid' ] , json_return , json_full_ret ] ] , } ] else : req = [ { 'measurement' : 'returns' , 'tags' : { 'fun' : ret [ 'fun' ] , 'id' : ret [ 'id' ] , 'jid' : ret [ 'jid' ] } , 'fields' : { 'return' : json_return , 'full_ret' : json_full_ret } } ] try : serv . write_points ( req ) except Exception as ex : log . critical ( 'Failed to store return with InfluxDB returner: %s' , ex )
Return data to a influxdb data store