Skip to content

Instantly share code, notes, and snippets.

View ddikman's full-sized avatar

David Dikman ddikman

View GitHub Profile
@ddikman
ddikman / filebeat-example.yml
Created January 28, 2016 14:00
Example of a filebeat config
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 January 28, 2016 14:09
Shell command to run logstash with config
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 June 19, 2018 16:47
Example of a filebeat to logstash to elasticsearch config
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 February 1, 2016 10:19
Example of a serilog configuration in json
{
"Logging": [
{
"key": "minimum-level",
"value": "Debug"
},
{
"key": "using:RollingFile",
"value": "Serilog.Sinks.RollingFile"
},
@ddikman
ddikman / LoggerSettings.cs
Created February 1, 2016 10:20
Serilog Json configuration reader
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 February 1, 2016 10:22
Example of how to read serilog configuration and add into Asp Net 5
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 February 3, 2016 09:25
Simple command line script for aliasing commands
@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 December 26, 2023 02:42
Example class for file operation on high contention files
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
{
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 September 6, 2016 13:04
C# extension to dump the entire stack trace and hierarchy of an exception
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;
}