Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amccool/am.elasticsearch.tracelistener
A TraceListener posting to ElasticSearch
https://github.com/amccool/am.elasticsearch.tracelistener
diagnostics dotnet elasticsearch kibana logging tracelistener
Last synced: about 1 month ago
JSON representation
A TraceListener posting to ElasticSearch
- Host: GitHub
- URL: https://github.com/amccool/am.elasticsearch.tracelistener
- Owner: amccool
- License: mit
- Created: 2015-11-11T18:39:04.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2022-06-22T19:14:32.000Z (over 2 years ago)
- Last Synced: 2024-11-10T13:08:13.183Z (2 months ago)
- Topics: diagnostics, dotnet, elasticsearch, kibana, logging, tracelistener
- Language: C#
- Homepage:
- Size: 102 KB
- Stars: 9
- Watchers: 4
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AM.Elasticsearch.TraceListener
## 3.0 Release Notes
the _type submitted is being changed from `Trace` to `doc` in preparation to posting to Elasticsearch 6.x, as _type is being deprecated.
nuget version > then 2.x have this change
## 1.1 Release Notes
the attribute
`ElasticSearchIndex`
is redundant, its value is ignored. Next minor release it will be removed, which will cause a runtime failure at the first usage of the listener### Pull request builds
[![Build status](https://ci.appveyor.com/api/projects/status/1let8gsvksxjv50c?svg=true)](https://ci.appveyor.com/project/amccool/elasticsearch-diagnostics)
AM.Elasticsearch.TraceListener
### Master build
[![Build status](https://ci.appveyor.com/api/projects/status/1let8gsvksxjv50c/branch/master?svg=true)](https://ci.appveyor.com/project/amccool/elasticsearch-diagnostics/branch/master)
ElasticSearch TraceListener is a System.Diagnostics based TraceListener which submits trace events and data to ElasticSearch making them viewable with Kibana
## Getting Started
[![nuget downloads](https://img.shields.io/nuget/dt/AM.Elasticsearch.TraceListener.svg)](https://www.nuget.org/packages/AM.Elasticsearch.TraceListener/)
[![nuget version](https://img.shields.io/nuget/v/AM.Elasticsearch.TraceListener.svg)](https://www.nuget.org/packages/AM.Elasticsearch.TraceListener/)Install the package from nuget.org https://www.nuget.org/packages/AM.Elasticsearch.TraceListener/
```ps
Install-Package AM.Elasticsearch.TraceListener
```edit your app.config/web.config
The kibana format of the index is -yyyy-MM-dd-HH
## Usage
Trace.Write("sdgsgsgsgsgsgsgsgsgsgsg");
class MyBigFatGreekClass
{
private static readonly TraceSource _traceSource = new TraceSource("alextrace", SourceLevels.Error);
public void LoveAndMarriage()
{
_traceSource.TraceEvent(TraceEventType.Verbose, 0, "is {0} and all is well", DateTime.UtcNow);
int x = 0;
try
{
int y = 99999 / x;
}
catch(Exception ex)
{
_traceSource.TraceData(TraceEventType.Error, 119999911, ex);
}
}
public void DeathAndTaxes()
{
_traceSource.TraceData(TraceEventType.Warning, 119999911, DateTime.UtcNow);
}
}## Environmental setup
You need an ElasticSearch host, and likely you want Kibana to view the data
### setup your ElasticSearch host
try using docker
see https://elk-docker.readthedocs.io/
```bash
$ sudo docker run -p 5601:5601 -p 9200:9200 -p 5044:5044 -it --name elk sebp/elk
```### Run your traces to generate some data
Elasticsearch and Kibana needs some data to get started with
### Configure ElasticSearch and Kibana
Note that `trace` was used for the index prefix
go the kibana managment page
http://192.168.1.1:5601/app/kibana#/managementclick index patterns
http://192.168.1.1:5601/app/kibana#/management/kibana/indicesclick +Add New
type in the prefix you used (see above) `trace` adding a `dash`if you have data in ElasticSearch then it will display a Date field, which will be `UtcDateTime`