このライブラリにより、.NETのInfluxDBのクライアントになりやすくなります!
ライブラリの背後にある基本的なアイデアは、クエリを直接自分のクラスのオブジェクトに変えることができるはずであるということです。 Dapperなどのマイクロームとよく似ています。
目標は、将来LINQ構文をサポートできるようにしたいということです。
次のコマンドを使用してNugetを介してインストールします。
Install-Package Vibrant.InfluxDB.Client
パッケージはここにあります。
または、GitHubリリースの1つで単純につかむことができます。
ライブラリは、すべてのHTTP操作をInfluxDB(1.0+)で公開し、2つの主要な方法でデータを読み取り/書き込むために使用できます。
ライブラリの使用方法の簡単な例はこちらから入手できます。
保存するInfluxDBの行を表すクラスを定義することから始めます。
public class ComputerInfo
{
[ InfluxTimestamp ]
public DateTime Timestamp { get ; set ; }
[ InfluxTag ( "host" ) ]
public string Host { get ; set ; }
[ InfluxTag ( "region" ) ]
public string Region { get ; set ; }
[ InfluxField ( "cpu" ) ]
public double CPU { get ; set ; }
[ InfluxField ( "ram" ) ]
public long RAM { get ; set ; }
}Pocoクラスでは、これらのことを指定する必要があります。
クラスを定義したら、APIの主なエントリポイントである流入クライアントを使用する準備ができました。
データベースへの書き込み方法は次のとおりです。
private ComputerInfo [ ] CreateTypedRowsStartingAt ( DateTime start , int rows )
{
var rng = new Random ( ) ;
var regions = new [ ] { "west-eu" , "north-eu" , "west-us" , "east-us" , "asia" } ;
var hosts = new [ ] { "some-host" , "some-other-host" } ;
var timestamp = start ;
var infos = new ComputerInfo [ rows ] ;
for ( int i = 0 ; i < rows ; i ++ )
{
long ram = rng . Next ( int . MaxValue ) ;
double cpu = rng . NextDouble ( ) ;
string region = regions [ rng . Next ( regions . Length ) ] ;
string host = hosts [ rng . Next ( hosts . Length ) ] ;
var info = new ComputerInfo { Timestamp = timestamp , CPU = cpu , RAM = ram , Host = host , Region = region } ;
infos [ i ] = info ;
timestamp = timestamp . AddSeconds ( 1 ) ;
}
return infos ;
}
public async Task Should_Write_Typed_Rows_To_Database ( )
{
var client = new InfluxClient ( new Uri ( "http://localhost:8086" ) ) ;
var infos = CreateTypedRowsStartingAt ( new DateTime ( 2010 , 1 , 1 , 1 , 1 , 1 , DateTimeKind . Utc ) , 500 ) ;
await client . WriteAsync ( "mydb" , "myMeasurementName" , infos ) ;
}データベースから照会する方法は次のとおりです。
public async Task Should_Query_Typed_Data ( )
{
var resultSet = await client . ReadAsync < ComputerInfo > ( "mydb" , "SELECT * FROM myMeasurementName" ) ;
// resultSet will contain 1 result in the Results collection (or multiple if you execute multiple queries at once)
var result = resultSet . Results [ 0 ] ;
// result will contain 1 series in the Series collection (or potentially multiple if you specify a GROUP BY clause)
var series = result . Series [ 0 ] ;
// series.Rows will be the list of ComputerInfo that you queried for
foreach ( var row in series . Rows )
{
Console . WriteLine ( "Timestamp: " + row . Timestamp ) ;
Console . WriteLine ( "CPU: " + row . CPU ) ;
Console . WriteLine ( "RAM: " + row . RAM ) ;
// ...
}
}Pocoクラスは、すべてのユースケースに適合するわけではありません。これは、システムを実装すると明らかになり、コンパイル時にフィールド/タグが何であるかがわかりません。この場合、動的クラスを使用する必要があります。
これが機能するには、タグとフィールドの読み取り/書き込み方法を指定するインターフェイスIINFLUXROWを使用する必要があります。このライブラリには、辞書を使用し、DLRの基本的なサポートがあるこのインターフェイスの1つの実装が既に含まれています。このクラスは、dynamicinfluxrowと呼ばれます。
動的クラスを使用して書き込む方法は次のとおりです。
private DynamicInfluxRow [ ] CreateDynamicRowsStartingAt ( DateTime start , int rows )
{
var rng = new Random ( ) ;
var regions = new [ ] { "west-eu" , "north-eu" , "west-us" , "east-us" , "asia" } ;
var hosts = new [ ] { "some-host" , "some-other-host" } ;
var timestamp = start ;
var infos = new DynamicInfluxRow [ rows ] ;
for ( int i = 0 ; i < rows ; i ++ )
{
long ram = rng . Next ( int . MaxValue ) ;
double cpu = rng . NextDouble ( ) ;
string region = regions [ rng . Next ( regions . Length ) ] ;
string host = hosts [ rng . Next ( hosts . Length ) ] ;
var info = new DynamicInfluxRow ( ) ;
info . Fields . Add ( "cpu" , cpu ) ;
info . Fields . Add ( "ram" , ram ) ;
info . Tags . Add ( "host" , host ) ;
info . Tags . Add ( "region" , region ) ;
info . Timestamp = timestamp ;
infos [ i ] = info ;
timestamp = timestamp . AddSeconds ( 1 ) ;
}
return infos ;
}
public async Task Should_Write_Dynamic_Rows_To_Database ( )
{
var client = new InfluxClient ( new Uri ( "http://localhost:8086" ) ) ;
var infos = CreateDynamicRowsStartingAt ( new DateTime ( 2010 , 1 , 1 , 1 , 1 , 1 , DateTimeKind . Utc ) , 500 ) ;
await client . WriteAsync ( "mydb" , "myMeasurementName" , infos ) ;
}動的クラス、ユーザー定義のenums、およびDateTimesを使用している場合は、文字列と列挙/DateTimeを区別する方法がないため、フィールド/タグとしてサポートされていないことに注意してください。
また、このインターフェイスでカスタムタイムスタンプタイプまたはDateTimeOffsetを使用する場合は、汎用IINFLUXROWインターフェイスまたはDynamicInFluxRowクラスを使用できます。
データベースから照会する方法は次のとおりです。
public async Task Should_Query_Dynamic_Data ( )
{
var resultSet = await client . ReadAsync < DynamicInfluxRow > ( "mydb" , "SELECT * FROM myMeasurementName" ) ;
// resultSet will contain 1 result in the Results collection (or multiple if you execute multiple queries at once)
var result = resultSet . Results [ 0 ] ;
// result will contain 1 series in the Series collection (or potentially multiple if you specify a GROUP BY clause)
var series = result . Series [ 0 ] ;
// series.Rows will be the list of DynamicInfluxRow that you queried for (which can be cast to dynamic)
foreach ( dynamic row in series . Rows )
{
Console . WriteLine ( "Timestamp: " + row . time ) ; // Can also access row.Timestamp
Console . WriteLine ( "CPU: " + row . cpu ) ;
Console . WriteLine ( "RAM: " + row . ram ) ;
// ...
}
} 多くの場合、挿入している正確な構造を選択していない場合があります。返された列の名前を変更することを取得しているデータについて、いくつかの集約または計算を行っているかもしれません。
この場合、新しいクラスを定義して、InfloxComputedAttributeを使用できます。属性で指定された名前(タグまたはフィールド、集約または違反)に一致する列は、この属性とともにプロパティに入ります。
[ InfluxComputedAttribute ]クライアントがフィールドまたはタグであるかどうかをクライアントが知る方法がないため、この属性を持つクラスは挿入に使用しないでください。
IINFLUXROWインターフェイス(たとえばDynamicInFluxRow)を使用している場合、「Fields」コレクションは、特定の測定の既知のタグと一致しないすべての列で満たされます。
データベースから膨大な量のデータを取得する場合がありますが、実際には、一度にすべてをメモリに保つことは実行不可能です。この場合、InfluxDBが提供するチャンキング機能が必要です。この機能は、InfluxQueryOptionsクラスを介してチャンキングを可能にすることで活用できます。有効になった場合、クライアントはデータを取得しているときに、ChunkingオプションをInfloxDBに提供します。
ただし、デフォルトのReadAsync操作は、ユーザーにコントロールを返す前に、すべてのチャンクを読み取るだけです。チャンクごとにデータチャンクを読みたいシナリオをサポートするには、代わりにreadchunkedasyncというメソッドを使用できます。これにより、さまざまなタイプの結果セットが返され、すべてのチャンクを非同期的に反復的に繰り返すことができます(最初に作成したクエリの構造を維持しながら)。これがユニットテストから取られた例です。
[ Fact ]
public async Task Should_Write_And_Query_Deferred_Grouped_Data_With_Multi_Query ( )
{
var start = new DateTime ( 2011 , 1 , 1 , 1 , 1 , 1 , DateTimeKind . Utc ) ;
var infos = InfluxClientFixture . CreateTypedRowsStartingAt ( start , 5000 , false ) ;
await client . WriteAsync ( InfluxClientFixture . DatabaseName , "groupedComputerInfo4" , infos ) ;
await client . WriteAsync ( InfluxClientFixture . DatabaseName , "groupedComputerInfo5" , infos ) ;
var chunkedResultSet = await client . ReadChunkedAsync < ComputerInfo > (
InfluxClientFixture . DatabaseName ,
$ "SELECT * FROM groupedComputerInfo4 GROUP BY region;SELECT * FROM groupedComputerInfo5 GROUP BY region" ,
new InfluxQueryOptions { ChunkSize = 200 } ) ;
InfluxChunkedResult < ComputerInfo > currentResult ;
InfluxChunkedSeries < ComputerInfo > currentSerie ;
InfluxChunk < ComputerInfo > currentChunk ;
int resultCount = 0 ;
int serieCount = 0 ;
int rowCount = 0 ;
using ( chunkedResultSet )
{
while ( ( currentResult = await chunkedResultSet . GetNextResultAsync ( ) ) != null )
{
while ( ( currentSerie = await currentResult . GetNextSeriesAsync ( ) ) != null )
{
while ( ( currentChunk = await currentSerie . GetNextChunkAsync ( ) ) != null )
{
rowCount += currentChunk . Rows . Count ;
}
serieCount ++ ;
}
resultCount ++ ;
}
}
Assert . Equal ( 1 * 2 , resultCount ) ;
Assert . Equal ( InfluxClientFixture . Regions . Length * 2 , serieCount ) ;
Assert . Equal ( 5000 * 2 , rowCount ) ;
}C#の今後のバージョンでは、Async Enumerablesを繰り返す機能があり、この機能がヒットすると、それもサポートします。以下のビデオを参照してください:
https://channel9.msdn.com/blogs/seth-juarez/a-preview-of-8-with-mads-torgersen#time=16m30s
TimeZone句を指定すると、InfluxDBはオフセットでタイムスタンプを返します。 DateTimeOffsetまたはTimestampタイプとしてNullableのいずれかを使用して、返されたタイムスタンプにこのオフセットを保存できます。タイムスタンプのタイプとしてDateTimeまたはNullableを使用する場合、タイムスタンプは常にUTCに変換されます。
または、たとえばNodatimeなど、カスタムタイプをサポートするために独自のitymestampparserを実装することもできます。実装したら、流入液に登録できます。次のインターフェイスを実装するだけです。
/// <summary>
/// ITimestampParser is responsible for parsing the 'time' column
/// of data returned, allowing use of custom DateTime types.
/// </summary>
/// <typeparam name="TTimestamp"></typeparam>
public interface ITimestampParser < TTimestamp >
{
/// <summary>
/// Parses a epoch time (UTC) or ISO8601-timestamp (potentially with offset) to a date and time.
/// This is used when reading data from influxdb.
/// </summary>
/// <param name="precision">TimestampPrecision provided by the current InfluxQueryOptions.</param>
/// <param name="epochTimeLongOrIsoTimestampString">The raw value returned by the query.</param>
/// <returns>The parsed timestamp.</returns>
TTimestamp ToTimestamp ( TimestampPrecision ? precision , object epochTimeLongOrIsoTimestampString ) ;
/// <summary>
/// Converts the timestamp to epoch time (UTC). This is used when writing data to influxdb.
/// </summary>
/// <param name="precision">TimestampPrecision provided by the current InfluxWriteOptions.</param>
/// <param name="timestamp">The timestamp to convert.</param>
/// <returns>The UTC epoch time.</returns>
long ToEpoch ( TimestampPrecision precision , TTimestamp timestamp ) ;
} 多くの場合、単一の呼び出しを実行して、異なる測定名で複数の測定値に書き込みたいと思うかもしれません。
これは、POCOクラスに次のインターフェイスを実装することで実現できます。
/// <summary>
/// Interface that can be used to specify a per-row measurement name.
/// </summary>
public interface IHaveMeasurementName
{
/// <summary>
/// Gets or sets the measurement name.
/// </summary>
string MeasurementName { get ; set ; }
}
または、Pocoクラスのクラスまたはプロパティ定義に[流入測定]属性を配置します。
クラスでそれを使用する場合、次のように名前を指定する必要があります。
[ InfluxMeasurement ( "MyTableName" ) ]
public class ClassWithMeasurementName
{
[ InfluxTimestamp ]
internal DateTime Timestamp { get ; set ; }
[ InfluxField ( "cpu" ) ]
internal double ? CPU { get ; set ; }
}プロパティで使用する場合、名前を指定しないでください。プロパティ値(文字列である必要があります)を使用します。
public class ClassWithMeasurementName
{
[ InfluxTimestamp ]
internal DateTime Timestamp { get ; set ; }
[ InfluxField ( "cpu" ) ]
internal double ? CPU { get ; set ; }
[ InfluxMeasurement ]
public string TableName { get ; set ; }
}これらのアプローチのいずれかを使用する場合、次のオーバーロードwriteasyncメソッドを使用できます。これは、測定値を引数として取得しません。
public Task WriteAsync < TInfluxRow > ( string db , IEnumerable < TInfluxRow > rows )
public Task WriteAsync < TInfluxRow > ( string db , IEnumerable < TInfluxRow > rows , InfluxWriteOptions options )
動的クラスでこれを行いたい場合は、AngementDynamicInfluxrow(iHavemeasurementNameインターフェイスを実装する)を単純に使用できます。
複数のアプローチが使用されている場合にレコードを書くためにどの測定値を決定するかを決定するときに次の優先度が使用されます。
IhavemeasurementNameまたはInfluceMeasurementAttributeのプロパティを使用した場合、測定名は読み取り操作中にそのプロパティに書き込まれます。
流入液は、SQL注入の予防をサポートするパラメーターバインディングもサポートします。
これを使用するには、パラメーター「オブジェクトパラメーター」を取得するメソッドを使用するだけです。これは、Newtonsoft.jsonを介したJSONシリアル化をサポートする匿名オブジェクト、辞書、または任意のオブジェクトです。
オブジェクトまたは辞書の値をパラメーター化する場合、名前が実際のクエリにあるように、名前に$をプレフィックスしないでください。
これがそれがどのように見えるかの例です:
var resultSet = await client . ReadAsync < ComputerInfo > (
db ,
"SELECT * FROM myMeasurementName WHERE time >= $myParam" ,
new { myParam = new DateTime ( 2010 , 1 , 1 , 1 , 1 , 3 , DateTimeKind . Utc ) } ) ;このクライアントライブラリを介して通常使用する任意のタイプは、パラメーターとして使用できます。
InfluxDBと対話するためのメインインターフェイスを以下に見ることができます。
public interface IInfluxClient
{
/// <summary>
/// Gets the default query optionns.
/// </summary>
InfluxQueryOptions DefaultQueryOptions { get ; }
/// <summary>
/// Gets the default write options.
/// </summary>
InfluxWriteOptions DefaultWriteOptions { get ; }
/// <summary>
/// Gets or sets the timeout for all requests made.
/// </summary>
TimeSpan Timeout { get ; set ; }
/// <summary>
/// Gets the timestamp parser registry.
/// </summary>
ITimestampParserRegistry TimestampParserRegistry { get ; }
/// <summary>
/// Executes an arbitrary command that does not return a table.
/// </summary>
/// <param name="commandOrQuery"></param>
/// <param name="db"></param>
/// <param name="parameters"></param>
/// <returns></returns>
Task < InfluxResultSet > ExecuteOperationAsync ( string commandOrQuery , string db , object parameters ) ;
/// <summary>
/// Executes an arbitrary command that returns a table as a result.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="commandOrQuery"></param>
/// <param name="db"></param>
/// <param name="parameters"></param>
/// <returns></returns>
Task < InfluxResultSet < TInfluxRow > > ExecuteOperationAsync < TInfluxRow > ( string commandOrQuery , string db , object parameters ) where TInfluxRow : new ( ) ;
/// <summary>
/// Executes a ping and waits for the leader to respond.
/// </summary>
/// <param name="secondsToWaitForLeader"></param>
/// <returns></returns>
Task < InfluxPingResult > PingAsync ( int ? secondsToWaitForLeader ) ;
/// <summary>
/// Executes the query and returns the result with the specified query options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="query"></param>
/// <param name="db"></param>
/// <param name="options"></param>
/// <param name="parameters"></param>
/// <returns></returns>
Task < InfluxResultSet < TInfluxRow > > ReadAsync < TInfluxRow > ( string db , string query , object parameters , InfluxQueryOptions options ) where TInfluxRow : new ( ) ;
/// <summary>
/// Executes the query and returns a deferred result that can be iterated over as they
/// are returned by the database.
///
/// It does not make sense to use this method unless you are returning a big payload and
/// have enabled chunking through InfluxQueryOptions.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="db"></param>
/// <param name="query"></param>
/// <param name="options"></param>
/// <param name="parameters"></param>
/// <returns></returns>
Task < InfluxChunkedResultSet < TInfluxRow > > ReadChunkedAsync < TInfluxRow > ( string db , string query , object parameters , InfluxQueryOptions options ) where TInfluxRow : new ( ) ;
/// <summary>
/// Writes the rows with the specified write options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <param name="rows"></param>
/// <param name="options"></param>
/// <returns></returns>
Task WriteAsync < TInfluxRow > ( string db , string measurementName , IEnumerable < TInfluxRow > rows , InfluxWriteOptions options ) where TInfluxRow : new ( ) ;
/// <summary>
/// Deletes data in accordance with the specified query
/// </summary>
/// <param name="db"></param>
/// <param name="deleteQuery"></param>
/// <param name="parameters"></param>
/// <returns></returns>
Task < InfluxResult > DeleteAsync ( string db , string deleteQuery , object parameters ) ;
}このインターフェースに加えて、その上に構築される多くの拡張メソッドが提供されます。
public static class InfluxClientExtensions
{
#region Raw Operations
/// <summary>
/// Executes an arbitrary command that returns a table as a result.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="commandOrQuery"></param>
/// <param name="db"></param>
/// <returns></returns>
public static Task < InfluxResultSet < TInfluxRow > > ExecuteOperationAsync < TInfluxRow > ( this IInfluxClient client , string commandOrQuery , string db ) ;
/// <summary>
/// Executes an arbitrary command or query that returns a table as a result.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="commandOrQuery"></param>
/// <returns></returns>
public static Task < InfluxResultSet < TInfluxRow > > ExecuteOperationAsync < TInfluxRow > ( this IInfluxClient client , string commandOrQuery ) ;
/// <summary>
/// Executes an arbitrary command or query that returns a table as a result.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="commandOrQuery"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public static Task < InfluxResultSet < TInfluxRow > > ExecuteOperationAsync < TInfluxRow > ( this IInfluxClient client , string commandOrQuery , object parameters ) ;
/// <summary>
/// Executes an arbitrary command that does not return a table.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="commandOrQuery"></param>
/// <param name="db"></param>
/// <returns></returns>
public static Task < InfluxResultSet > ExecuteOperationAsync ( this IInfluxClient client , string commandOrQuery , string db ) ;
/// <summary>
/// Executes an arbitrary command that does not return a table.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="commandOrQuery"></param>
/// <returns></returns>
public static Task < InfluxResultSet > ExecuteOperationAsync ( this IInfluxClient client , string commandOrQuery ) ;
/// <summary>
/// Executes an arbitrary command that does not return a table.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="commandOrQuery"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public static Task < InfluxResultSet > ExecuteOperationAsync ( this IInfluxClient client , string commandOrQuery , object parameters ) ;
#endregion
#region System Monitoring
/// <summary>
/// Shows InfluxDB stats.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <returns></returns>
public static async Task < InfluxResult < TInfluxRow > > ShowStatsAsync < TInfluxRow > ( this IInfluxClient client ) ;
/// <summary>
/// Shows InfluxDB diagnostics.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <returns></returns>
public static async Task < InfluxResult < TInfluxRow > > ShowDiagnosticsAsync < TInfluxRow > ( this IInfluxClient client ) ;
/// <summary>
/// Shows Shards.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <returns></returns>
public static async Task < InfluxResult < ShardRow > > ShowShards ( this IInfluxClient client ) ;
#endregion
#region Authentication and Authorization
/// <summary>
/// CREATE a new admin user.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <returns></returns>
public static Task < InfluxResultSet > CreateAdminUserAsync ( this IInfluxClient client , string username , string password ) ;
/// <summary>
/// CREATE a new non-admin user.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <returns></returns>
public static async Task < InfluxResult > CreateUserAsync ( this IInfluxClient client , string username , string password ) ;
/// <summary>
/// GRANT administrative privileges to an existing user.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <returns></returns>
public static async Task < InfluxResult > GrantAdminPrivilegesAsync ( this IInfluxClient client , string username ) ;
/// <summary>
/// GRANT READ, WRITE or ALL database privileges to an existing user.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="privilege"></param>
/// <param name="db"></param>
/// <param name="username"></param>
/// <returns></returns>
public static async Task < InfluxResult > GrantPrivilegeAsync ( this IInfluxClient client , string db , DatabasePriviledge privilege , string username ) ;
/// <summary>
/// REVOKE administrative privileges from an admin user
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <returns></returns>
public static async Task < InfluxResult > RevokeAdminPrivilegesAsync ( this IInfluxClient client , string username ) ;
/// <summary>
/// REVOKE READ, WRITE, or ALL database privileges from an existing user.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="privilege"></param>
/// <param name="db"></param>
/// <param name="username"></param>
/// <returns></returns>
public static async Task < InfluxResult > RevokePrivilegeAsync ( this IInfluxClient client , string db , DatabasePriviledge privilege , string username ) ;
/// <summary>
/// SET a user’s password.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <returns></returns>
public static async Task < InfluxResult > SetPasswordAsync ( this IInfluxClient client , string username , string password ) ;
/// <summary>
/// DROP a user.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropUserAsync ( this IInfluxClient client , string username ) ;
/// <summary>
/// SHOW all existing users and their admin status.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <returns></returns>
public static async Task < InfluxResult < UserRow > > ShowUsersAsync ( this IInfluxClient client ) ;
/// <summary>
/// SHOW a user’s database privileges.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <returns></returns>
public static async Task < InfluxResult < GrantsRow > > ShowGrantsAsync ( this IInfluxClient client , string username ) ;
#endregion
#region Database Management
/// <summary>
/// Create a database with CREATE DATABASE.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult > CreateDatabaseAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// Delete a database with DROP DATABASE
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropDatabaseAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// Delete series with DROP SERIES
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropSeries ( this IInfluxClient client , string db , string measurementName ) ;
/// <summary>
/// Delete series with DROP SERIES
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <param name="where"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropSeries ( this IInfluxClient client , string db , string measurementName , string where ) ;
/// <summary>
/// Delete measurements with DROP MEASUREMENT
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="measurementName"></param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropMeasurementAsync ( this IInfluxClient client , string db , string measurementName ) ;
/// <summary>
/// Create retention policies with CREATE RETENTION POLICY
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="policyName"></param>
/// <param name="db"></param>
/// <param name="duration"></param>
/// <param name="replicationLevel"></param>
/// <param name="isDefault"></param>
/// <returns></returns>
public static async Task < InfluxResult > CreateRetentionPolicyAsync ( this IInfluxClient client , string db , string policyName , string duration , int replicationLevel , bool isDefault ) ;
/// <summary>
/// Create retention policies with CREATE RETENTION POLICY
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="policyName"></param>
/// <param name="db"></param>
/// <param name="duration"></param>
/// <param name="replicationLevel"></param>
/// <param name="shardGroupDuration"></param>
/// <param name="isDefault"></param>
/// <returns></returns>
public static async Task < InfluxResult > CreateRetentionPolicyAsync ( this IInfluxClient client , string db , string policyName , string duration , int replicationLevel , string shardGroupDuration , bool isDefault ) ;
/// <summary>
/// Modify retention policies with ALTER RETENTION POLICY
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="policyName"></param>
/// <param name="db"></param>
/// <param name="duration"></param>
/// <param name="replicationLevel"></param>
/// <param name="isDefault"></param>
/// <returns></returns>
public static async Task < InfluxResult > AlterRetentionPolicyAsync ( this IInfluxClient client , string db , string policyName , string duration , int replicationLevel , bool isDefault ) ;
/// <summary>
/// Modify retention policies with ALTER RETENTION POLICY
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="policyName"></param>
/// <param name="db"></param>
/// <param name="duration"></param>
/// <param name="replicationLevel"></param>
/// <param name="shardGroupDuration"></param>
/// <param name="isDefault"></param>
/// <returns></returns>
public static async Task < InfluxResult > AlterRetentionPolicyAsync ( this IInfluxClient client , string db , string policyName , string duration , int replicationLevel , string shardGroupDuration , bool isDefault ) ;
/// <summary>
/// Delete retention policies with DROP RETENTION POLICY
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="policyName"></param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropRetentionPolicyAsync ( this IInfluxClient client , string db , string policyName ) ;
#endregion
#region Continous Queries
/// <summary>
/// To see the continuous queries you have defined, query SHOW CONTINUOUS QUERIES and InfluxDB will return the name and query for each continuous query in the database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult < ContinuousQueryRow > > ShowContinuousQueries ( this IInfluxClient client , string db ) ;
/// <summary>
/// Creates a continuous query.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="name"></param>
/// <param name="db"></param>
/// <param name="continuousQuery"></param>
/// <returns></returns>
public static async Task < InfluxResult > CreateContinuousQuery ( this IInfluxClient client , string db , string name , string continuousQuery ) ;
/// <summary>
/// Drops a continuous query.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="name"></param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropContinuousQuery ( this IInfluxClient client , string db , string name ) ;
#endregion
#region Schema Exploration
/// <summary>
/// Get a list of all the databases in your system.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <returns></returns>
public static async Task < InfluxResult < DatabaseRow > > ShowDatabasesAsync ( this IInfluxClient client ) ;
/// <summary>
/// The SHOW RETENTION POLICIES query lists the existing retention policies on a given database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult < RetentionPolicyRow > > ShowRetentionPoliciesAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// The SHOW SERIES query returns the distinct series in your database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult < ShowSeriesRow > > ShowSeriesAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// The SHOW SERIES query returns the distinct series in your database.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <returns></returns>
public static async Task < InfluxResult < ShowSeriesRow > > ShowSeriesAsync ( this IInfluxClient client , string db , string measurementName ) ;
/// <summary>
/// The SHOW SERIES query returns the distinct series in your database.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <param name="where"></param>
/// <returns></returns>
public static async Task < InfluxResult < ShowSeriesRow > > ShowSeriesAsync ( this IInfluxClient client , string db , string measurementName , string where ) ;
/// <summary>
/// The SHOW MEASUREMENTS query returns the measurements in your database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult < MeasurementRow > > ShowMeasurementsAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// The SHOW MEASUREMENTS query returns the measurements in your database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="where"></param>
/// <returns></returns>
public static async Task < InfluxResult < MeasurementRow > > ShowMeasurementsAsync ( this IInfluxClient client , string db , string where ) ;
/// <summary>
/// The SHOW MEASUREMENTS query returns the measurements in your database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementRegex"></param>
/// <returns></returns>
public static async Task < InfluxResult < MeasurementRow > > ShowMeasurementsWithMeasurementAsync ( this IInfluxClient client , string db , string measurementRegex ) ;
/// <summary>
/// The SHOW MEASUREMENTS query returns the measurements in your database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementRegex"></param>
/// <param name="where"></param>
/// <returns></returns>
public static async Task < InfluxResult < MeasurementRow > > ShowMeasurementsWithMeasurementAsync ( this IInfluxClient client , string db , string measurementRegex , string where ) ;
/// <summary>
/// SHOW TAG KEYS returns the tag keys associated with each measurement.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult < TagKeyRow > > ShowTagKeysAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// SHOW TAG KEYS returns the tag keys associated with each measurement.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <returns></returns>
public static async Task < InfluxResult < TagKeyRow > > ShowTagKeysAsync ( this IInfluxClient client , string db , string measurementName ) ;
/// <summary>
/// The SHOW TAG VALUES query returns the set of tag values for a specific tag key across all measurements in the database.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="tagKey"></param>
/// <returns></returns>
public static async Task < InfluxResult < TInfluxRow > > ShowTagValuesAsAsync < TInfluxRow , TValue > ( this IInfluxClient client , string db , string tagKey ) ;
/// <summary>
/// The SHOW TAG VALUES query returns the set of tag values for a specific tag key across all measurements in the database.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="tagKey"></param>
/// <param name="measurementName"></param>
/// <returns></returns>
public static async Task < InfluxResult < TInfluxRow > > ShowTagValuesAsAsync < TInfluxRow , TValue > ( this IInfluxClient client , string db , string tagKey , string measurementName ) ;
/// <summary>
/// The SHOW TAG VALUES query returns the set of tag values for a specific tag key across all measurements in the database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="tagKey"></param>
/// <returns></returns>
public static Task < InfluxResult < TagValueRow > > ShowTagValuesAsync ( this IInfluxClient client , string db , string tagKey ) ;
/// <summary>
/// The SHOW TAG VALUES query returns the set of tag values for a specific tag key across all measurements in the database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="tagKey"></param>
/// <param name="measurementName"></param>
/// <returns></returns>
public static Task < InfluxResult < TagValueRow > > ShowTagValuesAsync ( this IInfluxClient client , string db , string tagKey , string measurementName ) ;
/// <summary>
/// The SHOW FIELD KEYS query returns the field keys across each measurement in the database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult < FieldKeyRow > > ShowFieldKeysAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// The SHOW FIELD KEYS query returns the field keys across each measurement in the database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <returns></returns>
public static async Task < InfluxResult < FieldKeyRow > > ShowFieldKeysAsync ( this IInfluxClient client , string db , string measurementName ) ;
#endregion
#region Ping
/// <summary>
/// Executes a ping.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <returns></returns>
public static Task < InfluxPingResult > PingAsync ( this IInfluxClient client ) ;
#endregion
#region Data Management
/// <summary>
/// Writes the rows with default write options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <param name="rows"></param>
/// <returns></returns>
public static Task WriteAsync < TInfluxRow > ( this IInfluxClient client , string db , string measurementName , IEnumerable < TInfluxRow > rows ) ;
/// <summary>
/// Writes the rows with default write options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="rows"></param>
/// <returns></returns>
public static Task WriteAsync < TInfluxRow > ( this IInfluxClient client , string db , IEnumerable < TInfluxRow > rows ) ;
/// <summary>
/// Writes the rows with the specified write options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="rows"></param>
/// <param name="options"></param>
/// <returns></returns>
public static Task WriteAsync < TInfluxRow > ( this IInfluxClient client , string db , IEnumerable < TInfluxRow > rows , InfluxWriteOptions options ) ;
/// <summary>
/// Executes the query and returns the result with the default query options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="query"></param>
/// <param name="db"></param>
/// <returns></returns>
public static Task < InfluxResultSet < TInfluxRow > > ReadAsync < TInfluxRow > ( this IInfluxClient client , string db , string query ) ;
/// <summary>
/// Executes the query and returns the result with the default query options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="query"></param>
/// <param name="db"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public static Task < InfluxResultSet < TInfluxRow > > ReadAsync < TInfluxRow > ( this IInfluxClient client , string db , string query , object parameters ) ;
/// <summary>
/// Executes the query and returns the result with the specified query options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="query"></param>
/// <param name="db"></param>
/// <param name="options"></param>
/// <returns></returns>
public static Task < InfluxResultSet < TInfluxRow > > ReadAsync < TInfluxRow > ( this IInfluxClient client , string db , string query , InfluxQueryOptions options ) ;
/// <summary>
/// Executes the query and returns a deferred result that can be iterated over as they
/// are returned by the database.
///
/// It does not make sense to use this method unless you are returning a big payload and
/// have enabled chunking through InfluxQueryOptions.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="query"></param>
/// <returns></returns>
public static Task < InfluxChunkedResultSet < TInfluxRow > > ReadChunkedAsync < TInfluxRow > ( this IInfluxClient client , string db , string query ) ;
/// <summary>
/// Executes the query and returns a deferred result that can be iterated over as they
/// are returned by the database.
///
/// It does not make sense to use this method unless you are returning a big payload and
/// have enabled chunking through InfluxQueryOptions.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="query"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public static Task < InfluxChunkedResultSet < TInfluxRow > > ReadChunkedAsync < TInfluxRow > ( this IInfluxClient client , string db , string query , object parameters ) ;
/// <summary>
/// Executes the query and returns a deferred result that can be iterated over as they
/// are returned by the database.
///
/// It does not make sense to use this method unless you are returning a big payload and
/// have enabled chunking through InfluxQueryOptions.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="query"></param>
/// <param name="options"></param>
/// <returns></returns>
public static Task < InfluxChunkedResultSet < TInfluxRow > > ReadChunkedAsync < TInfluxRow > ( this IInfluxClient client , string db , string query , InfluxQueryOptions options ) ;
/// <summary>
/// Deletes data in accordance with the specified query
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="deleteQuery"></param>
/// <returns></returns>
public static Task < InfluxResult > DeleteAsync ( this IInfluxClient client , string db , string deleteQuery ) ;
/// <summary>
/// Deletes all data older than the specified timestamp.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <param name="to"></param>
/// <returns></returns>
public static Task < InfluxResult > DeleteOlderThanAsync ( this IInfluxClient client , string db , string measurementName , DateTime to ) ;
/// <summary>
/// Deletes all data in the specified range.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <param name="from"></param>
/// <param name="to"></param>
/// <returns></returns>
public static Task < InfluxResult > DeleteRangeAsync ( this IInfluxClient client , string db , string measurementName , DateTime from , DateTime to ) ;
#endregion
}各パラメーターがどのようなものであるかについての正確な兆候を取得するには、InfluxDBが提供するドキュメントページを参照してください。