Skip to content

Instantly share code, notes, and snippets.

Avatar

David Dikman ddikman

View GitHub Profile
@ddikman
ddikman / filebeat-example.yml
Created Jan 28, 2016
Example of a filebeat config
View filebeat-example.yml
filebeat:
prospectors:
-
paths:
# - C:\Users\David\AppData\Local\Temp\UMS-logs\um-log*.log
- /var/log/um-log-*.log
encoding: plain
input_type: log
force_close_files: false
@ddikman
ddikman / run-logstash.sh
Created Jan 28, 2016
Shell command to run logstash with config
View run-logstash.sh
docker run -d -p 9300:9300 -v /home/ec2-user/:/var/logstash/ logstash logstash -f /var/logstash/logstash.conf
@ddikman
ddikman / logstash-example.conf
Last active Jun 19, 2018
Example of a filebeat to logstash to elasticsearch config
View logstash-example.conf
input {
beats {
port => 9300
type => beats
}
}
filter {
grok {
match => { "message" => "%{TOMCAT_DATESTAMP:DATETIME} \[%{WORD:level}\]%{SPACE}%{GREEDYDATA:message}" }
overwrite => [ "message" ]
@ddikman
ddikman / configuration.dev.json
Created Feb 1, 2016
Example of a serilog configuration in json
View configuration.dev.json
{
"Logging": [
{
"key": "minimum-level",
"value": "Debug"
},
{
"key": "using:RollingFile",
"value": "Serilog.Sinks.RollingFile"
},
@ddikman
ddikman / LoggerSettings.cs
Created Feb 1, 2016
Serilog Json configuration reader
View LoggerSettings.cs
public class LoggerSettings : ILoggerSettings
{
private readonly IConfigurationSection _configuration;
public LoggerSettings(IConfigurationSection configuration)
{
_configuration = configuration;
}
public IEnumerable<KeyValuePair<string, string>> Configurations
@ddikman
ddikman / Startup.cs
Created Feb 1, 2016
Example of how to read serilog configuration and add into Asp Net 5
View Startup.cs
public class Startup
{
public Startup(IHostingEnvironment env)
{
string configFile = $"config.{env.EnvironmentName}.json".ToLower();
var configBuilder = new ConfigurationBuilder().AddJsonFile(configFile);
Configuration = configBuilder.Build();
Log.Logger = new LoggerConfiguration()
.ReadFrom.Settings(new LoggerSettings(Configuration.GetSection("Logging")))
@ddikman
ddikman / alias.bat
Created Feb 3, 2016
Simple command line script for aliasing commands
View alias.bat
@ECHO off
IF "%1" == "" goto failUsage
WHERE alias.cmd > tmpPathFile
SET /p currdir= < tmpPathFile
del tmpPathFile
SET currdir=%currdir:alias.cmd=%
@ddikman
ddikman / ConcurrentFile.cs
Last active May 11, 2016
Example class for file operation on high contention files
View ConcurrentFile.cs
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
namespace Stuffsie
{
/// <summary>Wraps concurrent file operations, ensuring access is available to a file before reading or writing</summary>
public static class ConcurrentFile
{
View EnumerableExtensions.cs
public static class EnumerableExtensions
{
public static bool TryGetFirst<T>(this IEnumerable<T> source, Func<T, bool> predicate, out T result)
{
result = source.FirstOrDefault(predicate);
if (default(T) == null)
return result != null;
return default(T).Equals(result);
@ddikman
ddikman / ExceptionFormatterExtension.cs
Created Sep 6, 2016
C# extension to dump the entire stack trace and hierarchy of an exception
View ExceptionFormatterExtension.cs
public static class ExceptionFormatterExtension
{
public static string GetDump(this Exception e)
{
var exceptions = new Stack<Exception>();
while (e != null)
{
exceptions.Push(e);
e = e.InnerException;
}