How to insert/ingest Current timestamp into kusto table

2.8k Views Asked by At

I am trying to insert current datetime into table which has Datetime as datatype using the following query:

.ingest inline into table NoARR_Rollout_Status_Dummie <| @'datetime(2021-06-11)',Sam,Chay,Yes

Table was created using the following query:

.create table NoARR_Rollout_Status_Dummie ( Timestamp:datetime, Datacenter:string, Name:string, SurName:string, IsEmployee:string)

But when I try to see data in the table, I could not see TimeStamp being filled. Is there anything I am missing?

1

There are 1 best solutions below

0
On

the .ingest inline command parses the input (after the <|) as a CSV payload. therefore you cannot include variables in it.

an alternative to what you're trying to do would be using the .set-or-append command, e.g.:

.set-or-append NoARR_Rollout_Status_Dummie <|
    print Timestamp = datetime(2021-06-11),
          Name = 'Sam',
          SurName = 'Chay',
          IsEmployee = 'Yes'

NOTE, however, that ingesting a single or a few records in a single command is not recommended for production scenarios, as it created very small data shards and could negatively impact performance.

For queued ingestion, larger bulks are recommended: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/api/netfx/kusto-ingest-best-practices#optimizing-for-throughput

otherwise, see if your use case meets the recommendations of streaming ingestion: https://learn.microsoft.com/en-us/azure/data-explorer/ingest-data-streaming