https://github.com/bcuff/elasticsearch-net-aws
Add-on to Elasticsearch.Net & NEST for using AWS's elasticsearch service.
https://github.com/bcuff/elasticsearch-net-aws
aws aws-elasticsearch c-sharp dot-net-client elasticsearch elasticsearch-net nest
Last synced: 29 days ago
JSON representation
Add-on to Elasticsearch.Net & NEST for using AWS's elasticsearch service.
- Host: GitHub
- URL: https://github.com/bcuff/elasticsearch-net-aws
- Owner: bcuff
- License: apache-2.0
- Created: 2015-10-19T19:38:12.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-09-27T19:09:16.000Z (over 2 years ago)
- Last Synced: 2025-03-08T09:05:37.577Z (2 months ago)
- Topics: aws, aws-elasticsearch, c-sharp, dot-net-client, elasticsearch, elasticsearch-net, nest
- Language: C#
- Homepage:
- Size: 261 KB
- Stars: 72
- Watchers: 7
- Forks: 27
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Elasticsearch Net for Amazon AWS
Add-on to [elasticsearch-net / NEST](https://github.com/elastic/elasticsearch-net) for using AWS's elasticsearch service.
## Install Package
On Nuget:
* [Current Version 5.0+](https://www.nuget.org/packages/Elasticsearch.Net.Aws/)
* [NEST / Elasticsearch.Net 2.X](https://www.nuget.org/packages/bcuff.Elasticsearch.Net.Aws-v2/)
* [NEST / Elasticsearch.Net 1.X](https://www.nuget.org/packages/Elasticsearch.Net.Aws-v1/)```PowerShell
# For ElasticSearch.Net >= 5.0.0
Install-Package Elasticsearch.Net.Aws
# or for dotnet core
dotnet add package Elasticsearch.Net.Aws# For ElasticSearch.Net 2.X
Install-Package bcuff.Elasticsearch.Net.Aws-v2
# or for dotnet core
dotnet add package bcuff.Elasticsearch.Net.Aws-v2# For ElasticSearch.Net 1.X
Install-Package Elasticsearch.Net.Aws-v1
# or for dotnet core
dotnet add package Elasticsearch.Net.Aws-v1
```## Setup
### Elasticsearch.Net Version >= 2.0.2
Use Package [Elasticsearch.Net.Aws](https://www.nuget.org/packages/Elasticsearch.Net.Aws/).
#### Typical Setup
```csharp
// for NEST// This constructor will look up AWS credentials in the
// same way that the AWSSDK does automatically.
var httpConnection = new AwsHttpConnection();var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var config = new ConnectionSettings(pool, httpConnection);
var client = new ElasticClient(config);
```#### .NET Core Applications using IConfiguration
```csharp
IConfiguration config = Configuration;
var options = config.GetAWSOptions();
var httpConnection = new AwsHttpConnection(options);// same as above
```#### Elasticsearch.Net Version 1.7.1
Use Package [Elasticsearch.Net.Aws-v1](https://www.nuget.org/packages/Elasticsearch.Net.Aws-v1)
Source for this version is maintained on the version-1 branch
```csharp
// for NEST
var client = new ElasticClient(settings, connection: new AwsHttpConnection(settings, new AwsSettings
{
AccessKey = "My AWS access key",
SecretKey = "My AWS secret key",
Region = "us-east-1",
}));
```The `AwsHttpConnection` class is an implemenation of `IConnection` that will sign the HTTP requests according to the [Version 4 Signing Process](http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html).
#### Serilog Sink Setup
In Code
```csharp
const string esUrl = "https://aws-es-thinger.us-west-1.es.amazonaws.com";
Log.Logger = new LoggerConfiguration()
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(esUrl))
{
ModifyConnectionSettings = conn =>
{
var httpConnection = new AwsHttpConnection("us-east-1");
var pool = new SingleNodeConnectionPool(new Uri(esUrl));
return new ConnectionConfiguration(pool, httpConnection);
}
})
.CreateLogger();
```In Configuration
```json
{
"Serilog": {
"Using": ["Serilog", "Serilog.Exceptions", "Serilog.Sinks.Elasticsearch", "Serilog.Enrichers.Environment", "Serilog.Enrichers.Process"],
"MinimumLevel": "Debug",
"WriteTo": [{
"Name": "Elasticsearch",
"Args": {
"nodeUris": "https://******.us-east-1.es.amazonaws.com",
"numberOfShards": 5,
"numberOfReplicas": 10,
"connection": "Elasticsearch.Net.Aws.AwsHttpConnection, Elasticsearch.Net.Aws"
}
}
],
"Enrich": ["FromLogContext", "WithMachineName", "WithExceptionDetails"],
}
}
```