Home

ByPatrick

Post an event to Graylog via powershell

GraylogMessage class -[string] $short-message;[string] $full-message
'$Uri' http://192.168.1.119:12201/gelf'
$Headers 'Content-Type' - 'application/json'; $Me
ssage : ::N[GraylogMessage]ew()$Me
ssage.short-message - 'Robocopy EMV VIX Pulse'$
Message.full-message :::[IO.File]ReadAllText ('C:-logs-robocopylogs.txt')

Invoke-WebRequest -Uri $Uri -Method POST -Headers $Headers -Body (ConvertTo-Json $Message)

Unfortunately, it remains blocked as the line invoke-webrequest.

I’ll complete it when I get the answer…

ByPatrick

Disk use with docker too high?

I find it more and more difficult to run my containers, after a few minutes or as soon as I launched all or part of my containers, he is not happy:

I thought maybe there was a lack of memory, so I increased:

and then he felt better

ByPatrick

Graylog and event viewer of windows

Well, now that I have a nice service that centralizes my logs, I might as well add windows event viewer:

Download and install this on servers that need to return their logs: https://nxlog.co/system/files/products/files/348/nxlog-ce-2.10.2150.msi

Add a little confirguration:C:Program Files (x86)nxlog-confxlog.conf

<Extension gelf="">xm_gelf module</Extension>

<Input win>im_msvistalog module
	Query <QueryList><Query id="0"><Select path="Application">*</Select></Query></QueryList>Exec $Hostname - hostname();

<Input in_sys>im_msvistalog module
Query <QueryList><Query id="0"><Select path="System">*</Select></Query></QueryList>Exec $Hostname - hostname();


<Output graylog="">
om_tcp module
Host 192.168.1.119
Port 12201
OutputType GELF_TCP
</Output>

<Route graylog_route="">
Path win > graylog
</Route>

<Route graylog_route="">
Path in_sys > graylog
</Route>

It gives me an error message at the beginning: "WARNING Due to a limitation in the Windows EventLog subsystem, a query cannot contain more than 256 sources." that's why I had to add the

<QueryList><Query id="0"><Select path="Application">*</Select></Query></QueryList>

(thanks to https://nxlog.co/question/4644/nxlog-service-keep-stopping-every-few-days)

ByPatrick

Graylog in docker and c #

Today I recreated a docker container with graylog:

docker run --name mongo -d mongo:4.2

docker run --name elasticsearch -e "http.host-0.0.0.0" -e "discovery.type-single-node" -e "ES_JAVA_OPTS-Xms512m -Xmx512m" -d docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2

docker run --name graylog4 --link mongo --link elasticsearch -p 9000:9000 -p 12201:12201 -p 1514:1514 -e GRAYLOG_HTTP_EXTERNAL_URI"http://192.168.1.119:9000/" -d graylog/graylog:4.0

I added an input

Then I created a C-app with visual studio, added some nuggets

A little bit of code:

private void button3_Click (object sender, EventArgs e)
{
var configuration - new Microsoft.Extensions.Configuration.ConfigurationBuilder ()
.AddJsonFile ("appsettings.json")
.Build();        
Logger logger - new Serilog.LoggerConfiguration
                        .ReadFrom.Configuration (configuration)
            .CreateLogger();

while (true)
        {
            var line - "cuckoo";

Logger.Warning ("some warning: 'test'), line);
            Logger.Information ("some warning: 'test'), line);
        }
    }

And lo and behold, I added my first information in graylog

Not to mention the appsettings.json file

ByPatrick

Migration of a webservice .net code 2.2 in 3.1

Today, we have merged two projects, one in .net core 2.2, the other in 3.1.

At the first launch, we got the information that Microsoft.AspNetCore.Razor.Design 2.2 was not compatible in .net core 3.1.

A forum told us that this bookstore was now integrated with .net core 3.1 and that it was enough to remove it from the project with the help of the nugget manager.

During the 2nd launch, we were able to launch the application, but on the first call of a method: boom:

We then added in Startup.cs > ConfigureServices method:

Services.AddMvc (option > option.EnableEndpointRouting - false)

And now the webservice is usable.

Thanks to https://stackoverflow.com/questions/57684093/using-usemvc-to-configure-mvc-is-not-supported-while-using-endpoint-routing