Giter Site home page Giter Site logo

refactorthis / elmah.io.elasticsearch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from elmahio/elmah.io.elasticsearch

0.0 3.0 0.0 817 KB

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

License: Apache License 2.0

C# 99.78% ASP 0.22%

elmah.io.elasticsearch's Introduction

Elmah.Io.ElasticSearch

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

install from nugetdownloads

Builds:
teamcity

Release 1.2 is live! Release Notes

QuickStart

Elmah.Io.ElasticSearch is configured like other implementations for Elmah. To get started, add the following to your web.config or app.config:

1. Connection String

2. <elmah> configuration section

    <connectionStrings>
        <add name="ElmahElasticSearch" connectionString="Nodes=http://localhost:9200,http://server2:9200, http://server3:9200;DefaultIndex=elmah;Username=elmahUser;Password=elmahPass" />
    </connectionStrings>
    <elmah>
        <errorLog type="Elmah.Io.ElasticSearch.ElasticSearchErrorLog, Elmah.Io.ElasticSearch"
        connectionStringName="ElmahIoElasticSearch" />
    </elmah>

Configuration

The ElasticSearch connection string supports the following information:

1. Specify Node URL(s)

A list of 1 to N Nodes - This is a comma separated list of nodes for your ES cluster. Example of a single node:

        <add name="ElmahElasticSearch" connectionString="Nodes=http://localhost:9200;DefaultIndex=elmah" />

Example of specifying 3 nodes:

<connectionStrings>
    <add name="ElmahElasticSearch" connectionString="Nodes=http://localhost:9200,http://server2:9200, http://server3:9200;DefaultIndex=elmah" />
</connectionStrings>

2. Specify Default index

The default index for Elmah can be specified as a static index.

In this example the index has the name "elmahIndex1"

<connectionStrings>
    <add name="ElmahElasticSearch" connectionString="Nodes=http://localhost:9200,http://server2:9200, http://server3:9200;DefaultIndex=elmahIndex1;" />
</connectionStrings>

The index can also be specified as a rolling index. In the example below the index uses the current day, month, and year.

<connectionStrings>
    <add name="ElmahElasticSearch" connectionString="Nodes=http://localhost:9200,http://server2:9200, http://server3:9200;DefaultIndex=elmah-${yyyy.MM.dd};" />
</connectionStrings>

3. Specify a username and password for use with ElasticSearch Shield.

<connectionStrings>
    <add name="ElmahElasticSearch" connectionString="Nodes=http://localhost:9200,http://server2:9200, http://server3:9200;DefaultIndex=elmah;Username=elmahUser;Password=elmahPass" />
</connectionStrings>

When using ES Shield here are the recommended settings for a user role with the name 'elmah'

elmah:
  indices:
    'elmah':
      privileges: read, index, indices:admin/get, indices:admin/exists, indices:admin/mapping/put, create_index

The user needs to be able to check if the index exists and if it does not exist it needs to be able to create the index plus apply the mapping.

4. <elmah> configuration

  <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>

In the example above you can see the following optional fields have been specified:

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

You can see a sample web.config that has both the <elmah> configuration and the connection string [here] (Elmah.Io.ElasticSearch.Web/Web.config)

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

elmah.io.elasticsearch's People

Contributors

bensmind avatar jayhilden avatar mpdreamz avatar smurfpandey avatar thomasardal avatar trymbeast avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.