이 라이브러리는 .NET에서 influxDB의 클라이언트가되기 쉽습니다!
도서관의 기본 아이디어는 쿼리를 자신의 클래스의 객체로 직접 전환 할 수 있어야한다는 것입니다. Dapper와 같은 Micro-oms와 매우 유사합니다.
목표는 향후 LINQ 구문을 지원할 수 있기를 원한다는 것입니다.
다음 명령과 함께 Nuget을 통해 설치하십시오.
Install-Package Vibrant.InfluxDB.Client
패키지는 여기에서 찾을 수 있습니다.
또는 단순히 Github 릴리스 중 하나에서 가져올 수 있습니다.
이 라이브러리는 인기도 (1.0+)에 대한 모든 HTTP 작업을 노출 시키며 두 가지 주요 방식으로 데이터를 읽거나 쓰는 데 사용될 수 있습니다.
라이브러리 사용 방법에 대한 간단한 예는 여기에서 제공됩니다.
저장하려는 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을 기본적으로 지원하는이 인터페이스 중 하나가 포함되어 있습니다. 이 클래스를 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 ) ;
}문자열과 열거/데이터 타임을 구별 할 수있는 방법이 없으므로 동적 클래스, 사용자 정의 열거 및 DateTimes를 필드/태그를 지원하지 않으므로 동적 클래스, 사용자 정의 열거 및 DateTimes를 사용하는 경우에 유의하십시오.
또한이 인터페이스에서 사용자 정의 타임 스탬프 유형 또는 DateTeMeOffset을 사용하려면 일반적인 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 ) ;
// ...
}
} 종종 삽입하는 정확한 구조를 선택하지 않을 수 있습니다. 아마도 반환 된 열의 이름을 변경하는 데이터에 대한 집계 또는 계산을 수행하고있을 수도 있습니다.
이 경우 새 클래스를 정의하고 infuxcomputedAttribute를 사용할 수 있습니다. 속성 (태그 또는 필드, 집계 여부)에 지정된 이름과 일치하는 모든 열은이 속성으로 속성에 들어갑니다.
[ InfluxComputedAttribute ]클라이언트가 필드인지 태그인지 알 수있는 방법이 없으므로이 속성의 클래스는 삽입에 사용해서는 안됩니다.
iinfluxrow 인터페이스 (예 : DynamicinFluxrow,)를 사용하는 경우 "필드"컬렉션에는 특정 측정에 대해 알려진 태그와 일치하지 않는 모든 열이 채워집니다.
때로는 데이터베이스에서 막대한 양의 데이터를 검색 할 수 있습니다. 실제로 한 번에 메모리에 모두 유지할 수 없을 정도로 많은 데이터가 가능합니다. 이 경우 InfuxDB에서 제공하는 청킹 기능이 필요합니다. 유입 퀴어 옵션 클래스를 통해 청킹을 활성화 하여이 기능을 활용할 수 있습니다. 활성화되면 클라이언트가 데이터를 검색 할 때 덩어리 옵션을 유입 할 수 있습니다.
그러나 기본 readasync 작업은 사용자에게 컨트롤을 반환하기 전에 모든 청크를 읽습니다. Chunk로 데이터 청크를 읽으려는 시나리오를 지원하려면 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# 버전에는 비동기 열거성을 반복 할 수있는 기능이 있으며,이 기능이 발생하면이 기능도 지원할 것입니다. 아래 비디오를 참조하십시오.
https://channel9.msdn.com/blogs/seth-juarez/a-preview-of-c-8-with-mads-torgersen#time=16m30s
TimeZone 절을 지정할 때 InfuxDB는 오프셋으로 타임 스탬프를 반환합니다. dateTimeOffset 또는 nullable을 타임 스탬프 유형으로 사용하여 반환 된 타임 스탬프 에서이 오프셋을 보존 할 수 있습니다. 타임 스탬프 유형으로 dateTime 또는 nullable을 사용하는 경우 타임 스탬프는 항상 UTC로 변환됩니다.
또는 자체 ITIMESTAMPPARSER를 구현하여 사용자 정의 유형 (예 : NODATIME)을 지원할 수 있습니다. 구현되면 유입 클라이언트에 등록 할 수 있습니다. 다음 인터페이스를 구현하기 만하면됩니다.
/// <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 ; }
}이러한 접근 방식 중 하나를 사용할 때는 다음 과부하기 writeSync 메소드를 사용할 수 있습니다.
public Task WriteAsync < TInfluxRow > ( string db , IEnumerable < TInfluxRow > rows )
public Task WriteAsync < TInfluxRow > ( string db , IEnumerable < TInfluxRow > rows , InfluxWriteOptions options )
동적 클래스 로이 작업을 수행하려면 iHaveMeaseRementName 인터페이스를 구현하는 이름의 DynamicinFluxrow를 사용하면 간단히 사용하면됩니다.
여러 접근 방식이 사용되는 경우 레코드를 작성할 측정을 결정할 때 다음과 같은 우선 순위가 사용됩니다.
IHAVEMEASUREMENTNAME 또는 유입 관리 기능이있는 속성을 사용하는 경우, 측정 이름은 읽기 작업 중에 해당 속성에 기록됩니다.
유입 클라이언트는 또한 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
}각 매개 변수에 대한 정확한 표시를 얻으려면 InfuxDB가 제공 한 문서 페이지를 참조하십시오.