lairtonb / serimongo

Real-time log viewer for serilog-sinks-mongodb.
Apache License 2.0
6 stars 0 forks source link

Getting started guide #22

Open SamKr opened 11 months ago

SamKr commented 11 months ago

This looks very promising, but have to say this is quite hard to get up and running. As a C# dev, took me a while to realise I need nodejs for the interface. Been installing, tweaking and trying for an hour, but I can't get it to execute.

Could you perhaps add a guide on getting started? Looking at the PRs I'd also need specific Angular versions, probably part of the reason I can't get it to execute.

lairtonb commented 11 months ago

Thanks @SamKr, this project was abandoned for quite some time, but thanks to your interest I'll update it to newer versions of .NET and Angular and release a new version soon, along with improved documentation.

SamKr commented 11 months ago

Ah wow that is awesome! Thanks a bunch :)

lairtonb commented 11 months ago

Interim update:

Not tested in latest version of MongoDB yet (only 4.4.x).

Will push probably Wednesday, end of day (GMT-3), with updated docs.

lairtonb commented 11 months ago

Could not finish it today as expected, but here a small update:

  1. Added initial docker-compose file to run Mongo DB in docker
  2. Moved development connection strings to user secrets

The second bullet is because the docker composer file creates root and app users, so the connection strings need to be updated accordingly, but without storing them in appsettings.json directly.

Additionally, the docker composer uses a .env file to read its variables, so .gitignore was updated to exclude it.

I expect to document these updates tomorrow.

I'm using this branch update-dependencies.

lairtonb commented 10 months ago

Added docker-compose.yml and added/updated related files.

Not to run it locally in docker is (all going well) as simple as:

docker-compose -p serimongo -f docker-compose.yml up -d

This will download all dependencies in docker, build the applications, setup Mongo DB with change streams and run everything:

image

Now I'm fine tuning and documenting everything, approaching the state where I'll be able to close this issue.

SamKr commented 10 months ago

Very nice 😄

lairtonb commented 10 months ago

I've updated the wiki with detailed instructions.

https://github.com/lairtonb/serimongo/wiki

I still have some ideas to improve the document and need to merge the changes to master, but I think it is nearly usable now.

If you have any feedback of things you'd like to see documented, please let me know.

SamKr commented 10 months ago

Oh wow, that's extensive. I'll start working on it tomorrow and let you know how it goes. Thanks for all your effort, really happy with this :)

SamKr commented 10 months ago

Sorry for the delay, bit backed up at work; I'll have time in the coming days.

SamKr commented 10 months ago

Okay so I've been playing around, and think I'm getting the general idea. One thing you might want to elaborate a bit more on, is what exactly are the Samples\SerilogSample and Samples\SeriMongoDesktopClient projects? What do they do?

The SeriMongoDesktopClient doesn't start with the following error:

image

Regarding the main project, I get it up and running up to the swagger page:

image

When I try to go to the localhost:4200 page, I get ERR_CONNECTION_REFUSED.

This error comes up in the output window:

MongoDB.Driver.MongoCommandException: Command aggregate failed: The $changeStream stage is only supported on replica sets.
   at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ProcessResponse(ConnectionId connectionId, CommandMessage responseMessage)
   at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.Execute(IConnection connection, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.Execute(IConnection connection, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`1 protocol, ICoreSession session, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult](ICoreSession session, ReadPreference readPreference, DatabaseNamespace databaseNamespace, BsonDocument command, IEnumerable`1 commandPayloads, IElementNameValidator commandValidator, BsonDocument additionalOptions, Action`1 postWriteAction, CommandResponseHandling responseHandling, IBsonSerializer`1 resultSerializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelHandle channel, ICoreSessionHandle session, ReadPreference readPreference, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.ExecuteAttempt(RetryableReadContext context, Int32 attempt, Nullable`1 transactionNumber, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Operations.RetryableReadOperationExecutor.Execute[TResult](IRetryableReadOperation`1 operation, RetryableReadContext context, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Operations.ReadCommandOperation`1.Execute(RetryableReadContext context, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Operations.AggregateOperation`1.Execute(RetryableReadContext context, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Operations.ChangeStreamOperation`1.ExecuteAggregateOperation(RetryableReadContext context, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Operations.ChangeStreamOperation`1.Execute(IReadBinding binding, CancellationToken cancellationToken)
   at MongoDB.Driver.OperationExecutor.ExecuteReadOperation[TResult](IReadBinding binding, IReadOperation`1 operation, CancellationToken cancellationToken)
   at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle session, IReadOperation`1 operation, ReadPreference readPreference, CancellationToken cancellationToken)
   at MongoDB.Driver.MongoCollectionImpl`1.ExecuteReadOperation[TResult](IClientSessionHandle session, IReadOperation`1 operation, CancellationToken cancellationToken)
   at MongoDB.Driver.MongoCollectionImpl`1.Watch[TResult](IClientSessionHandle session, PipelineDefinition`2 pipeline, ChangeStreamOptions options, CancellationToken cancellationToken)
   at MongoDB.Driver.MongoCollectionImpl`1.<>c__DisplayClass67_0`1.<Watch>b__0(IClientSessionHandle session)
   at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult](Func`2 func, CancellationToken cancellationToken)
   at MongoDB.Driver.MongoCollectionImpl`1.Watch[TResult](PipelineDefinition`2 pipeline, ChangeStreamOptions options, CancellationToken cancellationToken)
   at SeriMongo.Services.LogMonitorService.<StartMonitoring>b__5_0() in E:\Desktop\SourceCode\serimongo-master\SeriMongo\Services\LogMonitorService.cs:line 58

Thanks a lot so far! Let me know if you need any more information.

lairtonb commented 10 months ago

Sorry, I haven't merged it yet.

I'm using this branch: update-dependencies.

Do you want to checkout that branch and try the wiki instructions, or you prefer to wait until I merge this to master?

Those Samples\SerilogSample and Samples\SeriMongoDesktopClient projects are gone in the latest version.

I have left only these projects now:

image

lairtonb commented 10 months ago

The available projects in the latest version are:

Project Description
SeriMongo.Server.csproj API and SignalR server
SeriMongo.WebUI.Angular.cproj Angular CLI project creates from VS 2022 template to enable running in VS 2022 more easily
Serilog.Sinks.MongoDB.Sample.csproj Sample ASP.NET Core API project with Serilog and Serilog.Sinks.MongoDB with dynamic log level support
lairtonb commented 10 months ago

This week I'll edit the tutorial to clarify these pain points.

I am very grateful that you are trying to use this and helping me figure out where I can improve it.

SamKr commented 10 months ago

That's my bad, you mentioned that :x I used the right branch this time.

However, not much luck yet, starting the angular project error's out:

image

If you want, I have a very lengthy visualstudio-js-debugger.txt file.

I've launched both the API and the Angular project at the same time, same outcome, I've launched the Angular project from VS Code, same outcome. I modified all config files/secrets according to the wiki. Am I correct in thinking there's no way to provide an external db connection in the Angular project, only in the API? I can't set secrets in VS either.

What's the relationship between SeriMongo.Server and SeriMongo.WebUI.Angular? Do they require each other, or are they seperate tools?

Afterwards, I tried using docker-compose, and that worked - as in, I can get to the :4200 interface, which is awesome. But it's not connected to the db I provided in the .env file, it looks like the provided mongodb (I think?). How can I force it to use my external db? And there's no way to set a collection name, right?

Sorry if I'm making obvious mistakes, this is the first time I'm tinkering with an Angular project. Thanks for your help! It's been very educational so far.