Home > other >  KUSTO split txt when ingesting
KUSTO split txt when ingesting

Time:10-05

I created a table in my Azure Data Explorer with the following command:

.create table MyLogs ( Level:string, Timestamp:datetime, UserId:string, TraceId:string, Message:string, ProcessId:int32 )

I then created my Storage Account --> Container and i then uploaded a simple txt file with the following content

Level Timestamp UserId TraceId Message ProcessId

I then generated a SAS for the container holding that txt file and used in into the query section of my Azure Data Explorer like the following:

.ingest into table MyLogs (
h'...sas for my txt file ...')

Now, when i read the table i see something like this

Level                                            TimeStamp  UserId  TraceID  MEssage ProcessId
Level Timestamp UserId TraceId Message ProcessId

So it basically put all the content into the first column. I was expecting some automatic splitting. I tried with tab, spaces, commas and many other separators. I tried to configure an injection mapping with csv format but had no luck.

For what I understood, each new line in the txt is a new row in the table. But how to split the same line with some specific separator?

I read many pages of documentation but had no luck

CodePudding user response:

You can specify any of the formats that you want to try using the format argument, see the list of formats and the ingestion command syntax example that specify the format here

In addition, you can use the "one click ingestion" from the web interface.

CodePudding user response:

This should work (I have done it before with Python SDK)

.create table MyLogs ingestion csv mapping 'MyLogs_CSV_Mapping' [{"Name":"Level","datatype":"datetime","Ordinal":0},{"Name":"Timestamp","datatype":"datetime","Ordinal":1}, {"Name":"UserId","datatype":"string","Ordinal":2},{"Name":"TraceId","datatype":"string","Ordinal":3},{"Name":"Message","datatype":"string","Ordinal":4},{"Name":"ProcessId","datatype":"long","Ordinal":5}]

https://docs.microsoft.com/de-de/azure/data-explorer/kusto/management/data-ingestion/ingest-from-storage

.ingest into table MyLogs SourceDataLocator with (format="csv", ingestionMappingReference = "MyLogs_CSV_Mapping")

Hopefully this will help a bit :)

  • Related