influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

InfluxDB monitoring - add additional stats for measurement and series metadata

Open edbernier opened this issue 8 years ago • 5 comments

Feature Request

Proposal:

Requesting the ability to monitor the creation of measurements and series and track values per minute by measurement and series. Ranking them to make it easy to monitor the hot series and measurements.

This would provide observability into: measurement and series metadata: series creation timestamp; measurement creation timestamp; measurement rank by values per minute; series rank by values per minute. When a cluster changes behavior, it is common that the change is caused by a new application or a defect in an application submitting data. They want immediate visibility into that change.

Current Environment:

The existing queries (1) can’t be used in query cost modeling. (2) The existing queries can’t be used to make database object changes observable. (3) The existing queries can’t be used to explore data definitions in large cardinality databases.

Use case:

As a user, I want to explore existing measurements, series, tags, and fields to explore the series present in the database. Exploring means both discovering the existence and definition (series-key) of series as well as discovering key statistics (size on disk, write values per second, cardinality. From this information, I want to know what I can query - how to size my cluster - what database objects are sizing problems - and what cardinality of series a prospective query will read.

As a developer, I want access to series metadata to inform a query planning cost model. Storing something like a seconds-granularity, last-modified time per series-block could be really helpful in determining when a CQ needs to be re-run for backfilled/tombstoned data.

edbernier avatar May 18 '18 22:05 edbernier

To provide some context, we have a continuous deploy system that at any point could deploy substantial changes to code sending data to Influx. As an example this morning we had a deploy that caused data rate to jump from 4 Mbs into each telegraf host to 8 to 10.

image

This will be used both for frontline operations (blacklisting or managing sudden heavy senders) and also to help us inform teams of their overall contribution to utilization of our metrics infrastructure.

JimHagan avatar May 21 '18 14:05 JimHagan

This request as well as this complementary request for Telegraf-based rate limiting are key to our ops plan... https://github.com/influxdata/telegraf/issues/4171

JimHagan avatar May 21 '18 14:05 JimHagan

Here is a hacky Python script we've been using to generate some of this data. We have concerns about the performance of this...

QUERY_DB = 'telegraf'
SEND_ENDPOINT = 'telegrafc3.service.bo1.csnzoo.com'
SEND_PORT = 8094

STATS_MEASUREMENT_NAME = 'measurement_stats'

def get_timestamp(dt):
    return str(int(time.mktime(dt.timetuple()) * 1000000000))

def send_metric(metric): # InfluxDB Line Protocol
    sock = socket.socket(socket.AF_INET, # Internet
                         socket.SOCK_DGRAM) # UDP
    sock.sendto(metric, (SEND_ENDPOINT, SEND_PORT))

def get_measurements():
    url = '{0}/query'.format(QUERY_ENDPOINT, QUERY_DB)
    return requests.get(url, params = {'db': QUERY_DB, 'q': 'show measurements'}).json()['results'][0]['series'][0]['values']

def get_stats_for_measurement(m, stat='count(*)', timewindow='time > now() - 15m and time <= now() - 10m'):
    url = '{0}/query'.format(QUERY_ENDPOINT, QUERY_DB)
    query = 'select {0} from {1} where {2}'.format(stat, m, timewindow)
    print(query)
    try:
        return requests.get(url, params= {'db': QUERY_DB, 'q': query}, timeout=10).json()['results'][0]['series'][0]
    except:
        return None

if __name__=="__main__":
    measurements = get_measurements()
    print ("Processing {0} measurements".format(len(measurements)))
    for m in [_m[0] for _m in measurements]:
        stats = get_stats_for_measurement(m, 'count(*)')
        if stats is None:
            print ("Skipping {0}.  No data.".format(m))
            continue
        timestamp = get_timestamp(datetime.now())
        line_protocol = "{0},original_measurement_name={1} ".format(STATS_MEASUREMENT_NAME,m)
        cols = len(stats['columns'])
        for n in range(len(stats['columns'])):
            if stats['columns'][n] == 'time':
                continue
            else:
                orig_field_name = stats['columns'][n]
            line_protocol += '{0}={1}'.format('count', stats['values'][0][n])
            if n < cols - 1:
                line_protocol += ','
        line_protocol += ',original_field_name="{0}"'.format(orig_field_name)

        print(line_protocol)
        send_metric(line_protocol.encode('utf-8'))

JimHagan avatar May 23 '18 12:05 JimHagan

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.

stale[bot] avatar Jul 24 '19 13:07 stale[bot]

This issue has been automatically closed because it has not had recent activity. Please reopen if this issue is still important to you. Thank you for your contributions.

stale[bot] avatar Jul 31 '19 14:07 stale[bot]