def send_all_domain_metric_values()

in CWMetricsToOpenSearch/handler.py [0:0]


def send_all_domain_metric_values(values):
    total = 0
    total_flushed = 0
    for value in values:

        d = value._asdict()
        line_value = d.pop('value')
        metric_name = d['metric_name']
        d[metric_name] = line_value

        # Rename field timestamp to @timestamp
        timestamp_value = d.pop('timestamp')
        d['@timestamp'] = timestamp_value

        log_line = json.dumps(d)

        f, ignore = ES_BUFFER.add_log_line(log_line)

        total_flushed += f
        total += 1

    print('Added {} log lines to the buffer'.format(total))
    print('Flushed {} log lines'.format(total_flushed))