您的位置:首页 > 数据库 > Redis

.NET开源MSSQL、Redis监控产品Opserver之Exception配置

2017-05-24 15:34 441 查看

异常日志的记录和监控主要依赖于StackExchange.Exceptional组件,默认已经被引进来了。

先看下config文件夹下的ExceptionsSettings.json.example文件

{
"warningRecentCount": "100",           //警告提醒最近条目数,当超出该值在头部高亮显示警告
"criticalRecentCount": "200",          //严重警告提醒最近条目数,当超出该值在头部高亮显示严重警告
"viewGroups": "StatusExceptionsRO",    //安全模式“ad"下的分组查看权限设置
// You can have a simple applications list here, or a grouped structure when dealing with many apps.
//"applications": [                    //产生异常日志的程序
//  "Core",
//  "Chat",
//  "Stack Auth",
//  "StackExchange.com",
//  "API",
//  "API v2",
//  "Area 51",
//  "Status",
//  "Push Server",
//  "Sockets",
//  "Careers",
//  "BackOffice",
//  "Control Panel"
//],

//以分组在形式归类异常日志,未在groups定义的在others中显示
"groups": [
{
"name": "Core Q&A",
"applications": [
"Core",
"Chat",
"Stack Auth",
"StackExchange.com",
"API v2",
"Sockets",
"Area 51",
"Open ID",
"Stack Server",
"StackSnippets",
"Status"
]
},
{
"name": "Careers",
"applications": [
"Careers",
"BackOffice",
"BackOffice",
"Control Panel",
"StackShop",
"CareersAuth"
]
},
{
"name": "Mobile",
"applications": [
"Push Server"
]
},
{
"name": "Ads & Data",
"applications": [
"Prov Read API"
]
}
],
"stores": [      //异常日志存储位置
{
"name": "New York",
"queryTimeoutMs": 2000,
"pollIntervalSeconds": 10,
"connectionString": "Data Source=192.168.11.210;Initial Catalog=Opserver;User ID=sa;Password=Luzou+18518095396;"
}
],
  "stackTraceReplacements": [
    {
      "name": "github",
      "pattern": "(?<= in )https?://raw.githubusercontent.com/([^/]+/)([^/]+/)([^/]+/)(.*?):line (\\d+)",
      "replacement": "<a href=\"https://github.com/$1$2blob/$3$4#L$5\">$4:line $5</a>"
    }
  ] }

首先需要建一下数据库

CREATE TABLE [dbo].[Exceptions](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[GUID] [uniqueidentifier] NOT NULL,
[ApplicationName] [nvarchar](50) NOT NULL,
[MachineName] [nvarchar](50) NOT NULL,
[CreationDate] [datetime] NOT NULL,
[Type] [nvarchar](100) NOT NULL,
[IsProtected] [bit] NOT NULL,
[Host] [nvarchar](100) NULL,


<!-- Which ErrorStore to use, if no element is declared here a Memory store with defaults will be used -->
<!--<ErrorStore type="Memory" />-->
<!-- Other store types, common attributes:
- rollupSeconds: optional (default 600 seconds), determines how long the window is to roll up exceptions with the same stack trace - 0 to not roll up
- backupQueueSize: optional (default 1000), determines how many errors to cache (excluding rollups) in memory when logging fails...every 2 seconds we'll retry logging and flush these out to the final store -->
<!-- JSON: size defaults to 200, this is how many files are kept before the oldest error is removed -->
<!--<ErrorStore type="JSON" path="~/Errors" size="200" />-->
<!-- SQL: only a connection string or connection string name is needed, many applications can log to the same place as long as they have unique names (otherwise we can't tell them apart). -->
<!--<ErrorStore type="SQL" connectionString="Server=.;Database=Exceptions;Uid=Exceptions;Pwd=myPassword!" />-->
<!--<ErrorStore type="SQL" connectionStringName="MyConnectionString" />-->
<!-- You can also use a MySQL Database with the MySQL ErorrStore -->
<!--<ErrorStore type="MySQL" connectionString="Server=.;Database=Exceptions;Username=Exceptions;Pwd=myPassword!" />-->
<!--<ErrorStore type="MySQL" connectionStringName="MyConnectionString" />-->
View Code

好吧,其实这就搞定了,就是这么简单,然后上下效果图

 

Opserver系列目录 [url=http://www.cnblogs.com/xiaopotian/category/1007536.html]http://www.cnblogs.com/xiaopotian/category/1007536.html" target=_blank> [nvarchar](500) NULL, [HTTPMethod] [nvarchar](10) NULL, [IPAddress] [varchar](40) NULL, [Source] [nvarchar](100) NULL, [Message] [nvarchar](1000) NULL, [Detail] [nvarchar](max) NULL, [StatusCode] [int] NULL, [SQL] [nvarchar](max) NULL, [DeletionDate] [datetime] NULL, [FullJson] [nvarchar](max) NULL, [ErrorHash] [int] NULL, [DuplicateCount] [int] NOT NULL, CONSTRAINT [PK_Exceptions] PRIMARY KEY CLUSTERED ( [Id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO SET ANSI_PADDING OFF GO ALTER TABLE [dbo].[Exceptions] ADD DEFAULT ((0)) FOR [IsProtected] GO ALTER TABLE [dbo].[Exceptions] ADD DEFAULT ((1)) FOR [DuplicateCount] GO [/code]

然后webconfig下需要进行配置

<Exceptional applicationName="Status">
<ErrorStore type="SQL" connectionString="Data Source=192.168.11.210;Initial Catalog=Opserver;User ID=sa;Password=*******" />
</Exceptional>
<!-- Which ErrorStore to use, if no element is declared here a Memory store with defaults will be used -->
<!--<ErrorStore type="Memory" />-->
<!-- Other store types, common attributes:
- rollupSeconds: optional (default 600 seconds), determines how long the window is to roll up exceptions with the same stack trace - 0 to not roll up
- backupQueueSize: optional (default 1000), determines how many errors to cache (excluding rollups) in memory when logging fails...every 2 seconds we'll retry logging and flush these out to the final store -->
<!-- JSON: size defaults to 200, this is how many files are kept before the oldest error is removed -->
<!--<ErrorStore type="JSON" path="~/Errors" size="200" />-->
<!-- SQL: only a connection string or connection string name is needed, many applications can log to the same place as long as they have unique names (otherwise we can't tell them apart). -->
<!--<ErrorStore type="SQL" connectionString="Server=.;Database=Exceptions;Uid=Exceptions;Pwd=myPassword!" />-->
<!--<ErrorStore type="SQL" connectionStringName="MyConnectionString" />-->
<!-- You can also use a MySQL Database with the MySQL ErorrStore -->
<!--<ErrorStore type="MySQL" connectionString="Server=.;Database=Exceptions;Username=Exceptions;Pwd=myPassword!" />-->
<!--<ErrorStore type="MySQL" connectionStringName="MyConnectionString" />-->
View Code

好吧,其实这就搞定了,就是这么简单,然后上下效果图

 

Opserver系列目录 [url=http://www.cnblogs.com/xiaopotian/category/1007536.html]http://www.cnblogs.com/xiaopotian/category/1007536.html

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: