/// <summary> /// Use the kusto data reader and build an Elastic response. /// </summary> /// <param name="query">QueryData containing query information.</param> /// <param name="reader">Kusto IDataReader response.</param> /// <param name="timeTaken">TimeSpan representing query execution duration.</param> /// <param name="isSingleDoc">Indicates whether this was a single document query.</param> /// <returns>ElasticResponse object.</returns> private ElasticResponse ReadResponse( QueryData query, IDataReader reader, TimeSpan timeTaken) { var response = new ElasticResponse(); response.AddTook(timeTaken); Logger.LogTrace("Reading response using reader."); var parsedKustoResponse = ReadDataResponse(reader); if (parsedKustoResponse[AggregationTableName] != null) { Logger.LogTrace("Parsing aggregations"); // read aggregations foreach (DataRow row in parsedKustoResponse[AggregationTableName].TableData.Rows) { var bucket = BucketFactory.CreateFromDataRow(row); response.AddAggregation(bucket); } } else { // A ViewSingleDocument queries do not produce any aggregations used for total, // but Kibana expects this value response.AddToTotal(1); } // read hits Logger.LogDebug("Reading Hits using QueryData: {@query}", query.ToSensitiveData()); var hits = ReadHits(parsedKustoResponse, query); response.AddHits(hits); if (outputBackendQuery) { response.AppendBackendQuery(query.QueryCommandText); } return(response); }
public void Create_WithDateTime_ReturnsISOString() { // Arrange DataTable table = new DataTable(); table.Columns.Add("Timestamp", typeof(DateTime)).DateTimeMode = DataSetDateTime.Utc; table.Columns.Add("Count", typeof(int)); DataRow row = table.NewRow(); row["Timestamp"] = new DateTime(2017, 1, 2, 13, 4, 5, 60, DateTimeKind.Utc); row["Count"] = 234; // Act var bucket = BucketFactory.CreateFromDataRow(row); // Assert Assert.AreEqual("2017-01-02T13:04:05.060Z", bucket.KeyAsString); Assert.AreEqual(1483362245060, bucket.Key); Assert.AreEqual(234, bucket.DocCount); table.Dispose(); }