Comments (10)
Thanks a lot, your post and little snippet helped me figure out how I could integrate this. Turns out they have a ModifyConnectionSettings
hook, I just didn't really know how to use it.
If anyone else was curious (this would probably be better off posted in their repo, but oh well).
Here's a pretty crude example of how you could get it to work.
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-west-1", new StaticCredentialsProvider(
new AwsCredentials
{
// Service User Keys
AccessKey = "",
SecretKey = ""
}));
var pool = new SingleNodeConnectionPool(new Uri(esUrl));
return new ConnectionConfiguration(pool, httpConnection);
}
})
.CreateLogger();
Thanks a bunch for making this library! Saved me probably like 80 hours of fiddling with and trying to sign them requests!
from elasticsearch-net-aws.
It looks like you would probably need to fork the Serilog Elasticsearch Sink so that you can set up the client in a custom way. Maybe you can simply provide a setup overload that lets you inject a custom ElasticLowLevelClient instance or something and submit a PR back to the main line. https://github.com/serilog/serilog-sinks-elasticsearch/blob/dev/src/Serilog.Sinks.Elasticsearch/Sinks/ElasticSearch/ElasticsearchSinkState.cs#L84
You'll then need to setup an ElasticLowLevelClient instance like so
var httpConnection = new AwsHttpConnection("us-east-1");
var pool = new SingleNodeConnectionPool(new Uri("https://..."));
var config = new ConnectionConfiguration(pool, httpConnection);
var client = new ElasticLowLevelClient(config);
from elasticsearch-net-aws.
@KyleGobel I'm glad you figured that out.
That code example would be a good addition to the README. Feel free to PR it. I might do it myself if you don't :).
from elasticsearch-net-aws.
How would one provide basic auth credentials for the connection? In my use case, I have basic auth credentials (not AWS security credentials) that work in the browser, but not in the sink configuration.
from elasticsearch-net-aws.
@mariotacke I don't think AWS Elasticsearch Service supports basic http authentication. Either the request must be signed with valid AWS credentials or the inbound traffic needs to come from a whitelisted IP address. You can whitelist IP addresses in your elasticsearch domain's access policy.
from elasticsearch-net-aws.
Thanks @bcuff. I've asked my ops guys to give me proper credentials, that's probably the way to go.
from elasticsearch-net-aws.
Thanks a lot, your post and little snippet helped me figure out how I could integrate this. Turns out they have a
ModifyConnectionSettings
hook, I just didn't really know how to use it.If anyone else was curious (this would probably be better off posted in their repo, but oh well).
Here's a pretty crude example of how you could get it to work.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-west-1", new StaticCredentialsProvider( new AwsCredentials { // Service User Keys AccessKey = "", SecretKey = "" })); var pool = new SingleNodeConnectionPool(new Uri(esUrl)); return new ConnectionConfiguration(pool, httpConnection); } }) .CreateLogger();Thanks a bunch for making this library! Saved me probably like 80 hours of fiddling with and trying to sign them requests!
This works only in .net core with was elastic search. Can you help me on how to handle the same using with standard asp.net
from elasticsearch-net-aws.
You're welcome. Thanks for sharing the snippet!
from elasticsearch-net-aws.
@mariotacke Hi, any updates on this? I'm in a similar situation and searching web for a solution..
from elasticsearch-net-aws.
@orhunerdem, it's been a long time but IIRC, I ended up using AWS credentials instead of basic auth as suggested by @bcuff and @rtrscience .
from elasticsearch-net-aws.
Related Issues (20)
- How do I create a client with the V4 Signing process HOT 7
- Elasticsearch.Net v7 Support
- Started receiving 403 for a specific application with message about request signature HOT 3
- 7.0.0 - code not being signed HOT 8
- please release a version for .net target framework 4.7 HOT 2
- v6.1.0 Not Working With .NET Standard 2.0 HOT 1
- Issue with default AWS credentials and roles HOT 3
- AWS Credentials is null HOT 3
- how to setup .net 3.x aws connection HOT 2
- Suggestion HOT 1
- AWS4Signer HOT 1
- AWS Dependencies Issue HOT 2
- Any way to use this package with the latest version of Elasticsearch NEST? HOT 2
- Enabling Request/Response Causes Signature to be Rejected HOT 2
- AWS Dependency Issue HOT 3
- I want to fork but can't build due to missing key.snk public key HOT 2
- Authorization Header not passed in Request
- OpenSearch Serverless HOT 2
- Just updating from Elasticsearch.Net.Aws 7.2.1 to 7.2.2, causes 403 from AWS OpenSearch cluster HOT 6
- Highlight error with only 2 characters HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-net-aws.