Hi,
I am trying to insert a record into Elasticsearch using NEST. I need the timestamp to be indexed as "@timestamp" not "timestamp".
class Program
{
/// <summary>
///
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
var settings = new ConnectionSettings(new Uri("http://opselastic.elk.apps-ops.boitop.dev.cloud.******.com:9200")).DefaultIndex("apparea_apps");
var client = new ElasticClient(settings);
var typeUpdate = new health
{
@timestamp = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"),
apparea = "icross",
appname = "Test",
status = "green"
};
var IndexResponse = client.Index(typeUpdate)
;
}
}
/// <summary>
///
/// </summary>
class health
{
public string @timestamp { get; set; }
public string apparea { get; set; }
public string appname { get; set; }
public string status { get; set; }
}
}
What I expect:
{
"_index": "apparea_apps",
"_type": "health",
"_id": "AVxgGpY8yhns588mvFP4",
"_score": 1,
"_source": {
"@timestamp": "2017-05-31T15:00:00",
"apparea": "icross",
"appname": "Test",
"status": "green"
}
}
What I get
{
"_index": "apparea_apps",
"_type": "health",
"_id": "AVxgGpY8yhns588mvFP4",
"_score": 1,
"_source": {
"timestamp": "2017-05-31T15:00:00",
"apparea": "icross",
"appname": "Test",
"status": "green"
}
}
Notice the difference in the timestamp? How do I correct this?