Logging into kibana

18 Views Asked by At
public class JsonData
{
    public string Controller_Name { get; set; }
    public DateTime TimeStamp { get; set; }
    public long UnixTimeStamp { get; set; }
    public DomainDetails[] DomainData { get; set; }
}

public class DomainDetails
{
    public string Domain { get; set; }
    public string LicenseName { get; set; }
    public string UserName { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
    public string Email { get; set; }
    public string PhoneNo { get; set; }
}

public void LogInELK(String indexName, String activityType,Guid ID)
{         
    var elasticSearchURL = Configuration.ElasticSearchURL;

    if (String.IsNullOrEmpty(elasticSearchURL))
    {
        return;
    }

    var pool = new SingleNodeConnectionPool(new Uri(elasticSearchURL));

    ConnectionSettings settings;

    if (String.IsNullOrEmpty(Configuration.AWSRegionName))
    {
        settings = new ConnectionSettings(pool);
    }
    else
    {
        var httpConnection = new AwsHttpConnection(Configuration.AWSRegionName);

        settings = new ConnectionSettings(pool).BasicAuthentication(Configuration.ELKAuthUserName, Configuration.ELKAuthPassword).DefaultFieldNameInferrer(s  => s);
    }    

    settings.DisableDirectStreaming();

    var client = new ElasticClient(settings);

    var jsonData = new JsonData
                       {
                           Controller_Name = "Controller1",
                           TimeStamp = DateTime.UtcNow,
                           UnixTimeStamp = (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds,
                           DomainData = new[]
                                        {
                                            new DomainDetails
                                                {
                                                    Domain = "example1.com",
                                                    LicenseName = "License1",
                                                    UserName = "User1",
                                                    StartDate = DateTime.Parse("2022-03-01"),
                                                    EndDate = DateTime.Parse("2023-03-01"),
                                                    Email = "[email protected]",
                                                    PhoneNo = "111-111-1111"
                                                },
    new DomainDetails
    {
        Domain = "example2.com",
        LicenseName = "License2",
        UserName = "User2",
        StartDate = DateTime.Parse("2022-04-01"),
        EndDate = DateTime.Parse("2023-04-01"),
        Email = "[email protected]",
        PhoneNo = "222-222-2222"
    }
}
};
client.IndexAsync(jsonData, i => i.Index(indexName).Id(ID));

Here I am sending the jsonData in kiabna , but getting output as

_id : 87ea96e4-ee9b-43ce-a760-e6da8b75d51b
_index : license
_score
 - 

Controller_Name : Controller1

DomainData.Domain : [example1.com, example2.com]

DomainData.Email :[[email protected], [email protected]]
DomainData.EndDate : [Mar 1, 2023 @ 05:30:00.000, Apr 1, 2023 @ 05:30:00.000]

DomainData.LicenseName : [License1, License2]

DomainData.PhoneNo : [111-111-1111, 222-222-2222]

DomainData.StartDate : [Mar 1, 2022 @ 05:30:00.000, Apr 1, 2022 @ 05:30:00.000]

DomainData.UserName : [User1, User2]

TimeStamp : Feb 15, 2024 @ 20:20:15.031

UnixTimeStamp : 1,708,008,615

but my expected output is

  Controller_Name: "Controller1",
  TimeStamp : "2024-02-15T14:45:00",
  UnixTimeStamp : 1644945900
  DomainData: 
        {
            "Domain": "example1.com",
            "LicenseName": "License1",
            "UserName": "User1",
            "StartDate": "2022-03-01",
            "EndDate": "2023-03-01",
            "Email": "[email protected]",
            "PhoneNo": "111-111-1111"
            }

  Controller_Name": "Controller1",
  TimeStamp": "2024-02-15T14:45:00",
  UnixTimeStamp": 1644945900
    
            {
            "Domain": "example2.com",
            "LicenseName": "License2",
            "UserName": "User2",
            "StartDate": "2022-04-01",
            "EndDate": "2023-04-01",
            "Email": "[email protected]",
            "PhoneNo": "222-222-2222"
               }
0

There are 0 best solutions below