正在从事件中心将部分数据摄入Azure Data Explorer



我目前有一个Azure Data Explorer设置,用于从事件中心接收数据。由于某种我不知道的原因,我的摄入表只看到了大约45%的事件。我通过一次单独向事件中心发送100个事件来测试这一点。我知道我的事件中心正在接收这些事件,因为我设置了一个SQL表来接收这些事件并且该表正在接收100%的事件(在一个单独的使用者组下(。我的假设是我错误地设置了Azure Data Explorer表。

我有一个非常基本的对象,我正在发送

public class TestDocument
{
[JsonProperty("DocumentId")]
public string DocumentId { get; set; }

[JsonProperty("Title")]
public string Title { get; set; }
{

我已在Azure 中启用流接收

Azure Data Explorer > Configurations > Streaming ingestion (ON)

我已经在我的表中启用了流接收

.alter table TestTable policy streamingingestion enable

我的表格映射如下

.alter table TestTable ingestion json mapping "TestTable_mapping" '[{"column":"DocumentId","datatype":"string","Path":"$['DocumentId']"},{"column":"Title","datatype":"string","Path":"$['Title']"}]'

我的数据连接设置

Consumer group: Its own group    
Event system properties: 0
Table name: TestTable
Data format: JSON
Mapping name: TestTable_mapping

我这里缺了什么吗?一直以来,在发送的100个事件中,我只看到大约45-48个在我的桌子上被摄入。

编辑:

TestDocument 的Json有效载荷

{"DocumentId":"10","Title":"TEST"}

发现发生了什么,我正在向序列化的对象添加BOM,看起来ADX有问题。当我尝试在没有BOM的情况下序列化对象时,我能够看到从事件中心到ADX的所有数据流。

以下是我如何做到这一点的示例:

private static readonly JsonSerializer Serializer;
static SerializationHelper()
{
Serializer = JsonSerializer.Create(SerializationSettings);
}
public static void Serialize(Stream stream, object toSerialize)
{
using var streamWriter = new StreamWriter(stream, Encoding.UTF8, DefaultStreamBufferSize, true);
using var jsonWriter = new JsonTextWriter(streamWriter);
Serializer.Serialize(jsonWriter, toSerialize);
}

修复方法:

public static void Serialize(Stream stream, object toSerialize)
{
using var streamWriter = new StreamWriter(stream, new UTF8Encoding(false), DefaultStreamBufferSize, true);
using var jsonWriter = new JsonTextWriter(streamWriter);
Serializer.Serialize(jsonWriter, toSerialize);
}

最新更新