Skip to content

DennisGlindhart/Elmah.Io.ElasticSearch

 
 

Repository files navigation

Elmah.Io.ElasticSearch

Elmah.Io.ElasticSearch is an Elasticsearch storage backend for ELMAH.

install from nugetdownloads

Builds:
teamcity

#Release 1.1 is live! Release Notes

How

Elmah.Io.ElasticSearch is configured pretty much like every other storage implementation for Elmah. To get started, add the following to your web.config:

<connectionStrings>
    <add name="ElmahIoElasticSearch" connectionString="http://localhost:9200/elmah"/>
</connectionStrings>

<elmah>
    <errorLog type="Elmah.Io.ElasticSearch.ElasticSearchErrorLog, Elmah.Io.ElasticSearch"
    connectionStringName="ElmahIoElasticSearch" />
</elmah>

Replace the connection string URL with your Elasticsearch URL and add the elmah config section as explained on the offical ELMAH site.

##Configuration

The Elasticsearch index name can be specified one of two ways, let's say you want the index name to be elmahCurrent:

1: Put it in the connection string (preferred)

<connectionStrings>
    <add name="ElmahIoElasticSearch" connectionString="http://localhost:9200/elmahCurrent"/>
</connectionStrings>

2: Leave it off the connection string and put it in the elmah specification

<connectionStrings>
    <add name="ElmahIoElasticSearch" connectionString="http://localhost:9200"/>
</connectionStrings>

<errorLog
    type="Elmah.Io.ElasticSearch.ElasticSearchErrorLog, Elmah.Io.ElasticSearch"
    connectionStringName="ElmahIoElasticSearch"
    defaultIndex="elmahCurrent" />

You can optionally specify the following fields that will be written to search:

  1. Application Name
  2. Environment Name
  3. Customer Name

Specify these in the attribute:

  <elmah>
    <errorLog 
        type="Elmah.Io.ElasticSearch.ElasticSearchErrorLog, Elmah.Io.ElasticSearch, Version=1.0.0.0, Culture=neutral" 
        connectionStringName="ElmahElasticSearch" 
        applicationName="ElmahElasticSearchSampleWebsite"
        environmentName="development"
        customerName="sample customer"
        />
    <security allowRemoteAccess="false" />
  </elmah>

##Retreiving raw data To get the data from Elastic, run the following:

GET elmah/error/_search
{
  "query": {
    "match_all": {}
  }
}

Sample Result:

{
   "took": 4,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
         {
            "_index": "elmah",
            "_type": "error",
            "_id": "AUwupDKg5dFjuaEj8ID-",
            "_score": 1,
            "_source": {
               "errorXml": "<some xml/>",
               "applicationName": "ElmahElasticSearchSampleWebsite",
               "hostName": "VB-133",
               "type": "System.Web.HttpException",
               "source": "System.Web.Mvc",
               "message": "The controller for path '/asdfdsaf' was not found or does not implement IController.",
               "detail": "System.Web.HttpException (0x80004005): The controller for path '/asdfdsaf' was not found or does not implement IController.",
               "user": "",
               "@timestamp": "2015-03-18T15:47:35.0322548-05:00",
               "statusCode": 404,
               "webHostHtmlMessage": "",
               "environmentName": "development",
               "customerName": "sample customer"
            }
         }
      ]
   }
}

Respect

Build by TeamCity

About

Elmah.Io.ElasticSearch is a ElasticSearch storage backend for ELMAH.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.7%
  • Classic ASP 0.3%