Skip to content
This script allows to extract data stored in an Influx time series measurement into a CSV file. There is an option to replace existing tag values with new values.
PowerShell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
ExtractTransformInflux.ps1
LICENSE
README.md
show-InfluxTagCardinality.ps1

README.md

This repo hosts scripts assisting in the Influxdb analytics, and data extraction needs. It currently supports two use cases:

  1. ExtractTransformInflux Currently there is not a way to update the tags (like tag names, making a field a tag or a tag to filed) after the fact in InfluxDB. The ideal option would have been to have a simple update tag value command in Influxdb, but Influx design does not support such a feature at this time. Ref: #3904.

  2. show-InfluxTagCardinalityThere is not an easy way to show the cascaded cardinality; for example you have a series1 with m unique values, and series2 with n unique values etc. there isn't a way to get how many unique values (cardinality) in series2 for each of the values in series1. Given the TSM structure the m*n is what drives lot of capacity needs for Influx.

ExtractTransformInflux

This script allows to extract data stored in an Influx time series measurement into a CSV file. There is an option to replace existing tag values with new values. The resulting CSV file can be exported back to another Influx Measurement or updaloded to same one, and old series can be dropped.

SYNTAX

ExtractTransformInflux.ps1 [-influxBaseUrl] <String> [-measurement] <String> [[-oldTags] <String>] [[-newTags] <String>] [[-additionalFilter]
<String>] [[-batchSize] <Int32>] [[-outFile] <String>] [[-precision] <String>] [[-outtype] <String>] [[-timeformat] <String>] [<CommonParameters>]

PARAMETERS

-influxBaseUrl
    URL for the Influxdb query entry point (usually 8086 port), include the DB name as well e.g. "http://localhost:8086/query?db=InfluxerDB"
-measurement
    measurment to query from
-oldTags
    List of tags and their values to be replaced. Usage Pattern: <Tag=Value>. Separate multiple tags by a ;. e.g. "AppName=App1;Release=Beta". Optional parameter.
-newTags
    List of tags and their values to replace with. Usage Pattern: <Tag=Value>. Separate multiple tags by a ;. e.g. "AppName=MyApplication;Release=Pre_Beta". Mandatory if -oldTags is specified.
-additionalFilter
    Filters to restrict the points/series returned. Optional, but recommended
-batchSize
    Influx chunk size, defaults to 10000
-outFile
    Output file name, defaults to  ".\InfluxDump.csv"
-precision
    output precision, defaults to  seconds
-outtype
    output time format : text - logs in local system locale, epoch will use the epoch at $precison, Binary will be the .Net DateTIme Binary representation, defaults to text
-timeformat
    output time format when the -outtype is text, default will be upto micro second precision yyyy-MM-dd-hh.mm.ss.ffffff

Usage

.\ExtractTransformInflux.ps1 -influxBaseUrl "http://localhost:8086/query?db=TestDB" -measurement "MyMeasurement"  -oldTags "AppName=App1;Release=Beta" -newTags "AppName=MyApplication;Release=Pre_Beta"

show-InfluxTagCardinality

This script calculates the tag value cardinality. InfluxDB native implementation gives the value caridinality per tag key. But in real world situations we might want to know the unique values of one tag given each unique values of another tag. e.g. assume we track no sessions served by various docker instances, source IP, and geo location. So if we have to calculate number of unique IP address per geo location, default influx is not straight forward. This script comes handy in those situations.

SYNTAX

show-InfluxTagCardinality.ps1 [-influxBaseUrl] <String> [-measurement] <String> [[-tags] <String[]>]

PARAMETERS

-influxBaseUrl
    URL for the Influxdb query entry point (usually 8086 port), include the DB name as well e.g. "http://localhost:8086/query?db=InfluxerDB"
-measurement
    measurment to query from
-tags <String[]>
    array of tags which should be considered for cardinality calculation. 

Usage

.\show-InfluxTagCardinality.ps1 -influxBaseUrl "http://localhost:8086/query?db=TestDB" -measurement "MyMeasurement"  -tags @("GeoLocation,IP_Address")
You can’t perform that action at this time.