question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ElasticSearch Target Null

See original GitHub issue

Describe the bug When I try to Log data as target old and new data was store in db is like this { "customFields": { "ReferenceId": 12, "UserInfo": { "userId": "055a1227-fc72-4036-b827-1b77dc7c2cdd", "userName": "m.test", "remoteIpAddress": "::1", "localIpAddress": "::1", "osInfo": "Device: Other | Windows Version: 10.", "browserName": "Edge Version: 103.0" } }, "target": { "type": "Guild", "old": [ [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ] ], "new": [ [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ], [ [] ] ] }, "comments": [ "Guild به روز شد" ], "startDate": "2022-07-17T15:07:28.2990601Z", "endDate": "2022-07-17T15:07:31.8419572Z", "duration": 3543 }, } my connection string to elastic with audit is this : Audit.Core.Configuration.DataProvider = new ElasticsearchDataProvider() { ConnectionSettings = new ConnectionSettings(new SingleNodeConnectionPool(new Uri(https://user:pass@es01:9200))) .ConnectionLimit(-1) .ServerCertificateValidationCallback((o, certificate, arg3, arg4) => true), IndexBuilder = ev => ev.EventType.ToLower(), IdBuilder = ev => Guid.NewGuid() }; and my problem was start when i use https and ssl in elastic and use ConnectionSettings like this to bypass invalid certificate please help to solve this error my elastic search version : 8.3.2 Target .NET framework:

  • .NET Core 6

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
thepirat000commented, Jul 24, 2022

This was fixed on version 19.2.0, please upgrade your references and re-test

0reactions
thepirat000commented, Jul 22, 2022

I think the problem is in the pre-serialization made to the target object.

Changing this line:

https://github.com/thepirat000/Audit.NET/blob/b590bef777b7e2ba6005f78e49cb04d5407eabdb/src/Audit.NET.ElasticSearch/Providers/ElasticsearchDataProvider.cs#L82

To:

return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(value, AuditJsonNetSerializer.Settings), value.GetType(), AuditJsonNetSerializer.Settings);

Fixes the issue.

I will run some tests and eventually publish a fixed version of the library.

In the meantime you could override the Serialize<T> in a custom data provider inheriting from ElasticsearchDataProvider

Read more comments on GitHub >

github_iconTop Results From Across the Web

null_value | Elasticsearch Guide [7.17]
When a field is set to null , (or an empty array or an array of null values) it is treated as though...
Read more >
null-safe operator should detect target type as primitive
When we use the null-safe operator in Painless, we ignore the target type. This means that we may not know a null-safe operator...
Read more >
Missing vs. Empty Fields
In Elasticsearch, these values would indicate that a given field does exist: Empty strings, such as "" or "-". Arrays containing null and...
Read more >
No log data in Elasticsearch with NLog.Targets.ElasticSearch
I'm using docker containers for elasticsearch and kibana in my tests. also tried logging using console app (.net core 3.1) while creating the ......
Read more >
Source fields with null values are dropped when you write ...
To write the fields with null values in the target, perform the following steps: Configure an Elasticsearch mapping in advanced mode to read ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found