Elastic Kibana ve SQL kaldırıldı
This commit is contained in:
parent
1c3d8c5037
commit
507aad9b0e
10 changed files with 4032 additions and 140 deletions
15
api/src/Kurs.Platform.Domain/Entities/LogEntry.cs
Normal file
15
api/src/Kurs.Platform.Domain/Entities/LogEntry.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Text.Json;
|
||||
using Volo.Abp.Domain.Entities;
|
||||
|
||||
namespace Kurs.Platform.Entities;
|
||||
|
||||
public class LogEntry: Entity<Guid>
|
||||
{
|
||||
public DateTime Timestamp { get; set; }
|
||||
public string Level { get; set; }
|
||||
public string Message { get; set; }
|
||||
public string? MessageTemplate { get; set; }
|
||||
public string? Exception { get; set; }
|
||||
public JsonDocument? Properties { get; set; }
|
||||
}
|
||||
|
|
@ -39,6 +39,7 @@ public class PlatformDbContext :
|
|||
public DbSet<PublicApi> PublicApis { get; set; }
|
||||
public DbSet<GlobalSearch> GlobalSearchs { get; set; }
|
||||
public DbSet<AiBot> AiBots { get; set; }
|
||||
public DbSet<LogEntry> LogEntrys { get; set; }
|
||||
|
||||
#region Entities from the modules
|
||||
|
||||
|
|
@ -205,5 +206,11 @@ public class PlatformDbContext :
|
|||
b.ToTable(PlatformConsts.DbTablePrefix + nameof(AiBot), PlatformConsts.DbSchema);
|
||||
b.ConfigureByConvention();
|
||||
});
|
||||
|
||||
builder.Entity<LogEntry>(b =>
|
||||
{
|
||||
b.ToTable(PlatformConsts.DbTablePrefix + nameof(LogEntry), PlatformConsts.DbSchema);
|
||||
b.ConfigureByConvention();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
3915
api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20250507065018_LogEntry.Designer.cs
generated
Normal file
3915
api/src/Kurs.Platform.EntityFrameworkCore/Migrations/20250507065018_LogEntry.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Text.Json;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Kurs.Platform.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class LogEntry : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PLogEntry",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Timestamp = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
Level = table.Column<string>(type: "text", nullable: true, collation: "tr-x-icu"),
|
||||
Message = table.Column<string>(type: "text", nullable: true, collation: "tr-x-icu"),
|
||||
MessageTemplate = table.Column<string>(type: "text", nullable: true, collation: "tr-x-icu"),
|
||||
Exception = table.Column<string>(type: "text", nullable: true, collation: "tr-x-icu"),
|
||||
Properties = table.Column<JsonDocument>(type: "jsonb", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PLogEntry", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "PLogEntry");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
// <auto-generated />
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using Kurs.Platform.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
|
@ -1472,6 +1473,38 @@ namespace Kurs.Platform.Migrations
|
|||
b.ToTable("PListFormField", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kurs.Platform.Entities.LogEntry", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Exception")
|
||||
.HasColumnType("text")
|
||||
.UseCollation("tr-x-icu");
|
||||
|
||||
b.Property<string>("Level")
|
||||
.HasColumnType("text")
|
||||
.UseCollation("tr-x-icu");
|
||||
|
||||
b.Property<string>("Message")
|
||||
.HasColumnType("text")
|
||||
.UseCollation("tr-x-icu");
|
||||
|
||||
b.Property<string>("MessageTemplate")
|
||||
.HasColumnType("text")
|
||||
.UseCollation("tr-x-icu");
|
||||
|
||||
b.Property<JsonDocument>("Properties")
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<DateTime>("Timestamp")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("PLogEntry", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Kurs.Platform.Entities.Menu", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Async" Version="2.1.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
|
||||
<PackageReference Include="Elastic.Serilog.Sinks" Version="8.12.3" />
|
||||
<PackageReference Include="Serilog.Sinks.PostgreSQL" Version="2.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Elastic.Channels;
|
||||
using Elastic.Ingest.Elasticsearch;
|
||||
using Elastic.Ingest.Elasticsearch.DataStreams;
|
||||
using Elastic.Serilog.Sinks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
@ -23,31 +19,10 @@ public class Program
|
|||
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? ""}.json", true)
|
||||
.Build();
|
||||
|
||||
var url = configuration.GetValue<string>("Elastic:Url");
|
||||
var index = configuration.GetValue<string>("Elastic:Index");
|
||||
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(configuration)
|
||||
.WriteTo.Elasticsearch([new Uri(url)], opts =>
|
||||
{
|
||||
opts.DataStream = new DataStreamName("kurs_platform", "api_logs", index);
|
||||
opts.BootstrapMethod = BootstrapMethod.Failure;
|
||||
})
|
||||
.CreateLogger();
|
||||
|
||||
// Elastic.Serilog.Sinks paketi appsettings'ten okuyabilir hale gelince bu kullanılacak:
|
||||
/*
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "Elasticsearch",
|
||||
"Args": {
|
||||
"bootstrapMethod": "Failure",
|
||||
"nodes": ["http://localhost:9200"],
|
||||
"dataStream": "kurs_platform-api_logs-dev"
|
||||
}
|
||||
}
|
||||
]
|
||||
*/
|
||||
try
|
||||
{
|
||||
Log.Information("Starting Kurs.Platform.HttpApi.Host.");
|
||||
|
|
|
|||
|
|
@ -29,29 +29,33 @@
|
|||
"Index": "dev"
|
||||
},
|
||||
"Serilog": {
|
||||
"Using": ["Elastic.Serilog.Sinks", "Serilog.Sinks.Console"],
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"Microsoft": "Information",
|
||||
"Microsoft.EntityFrameworkCore": "Warning",
|
||||
"Microsoft.AspNetCore": "Warning",
|
||||
"OpenIddict": "Information"
|
||||
"Microsoft": "Warning",
|
||||
"System": "Warning"
|
||||
}
|
||||
},
|
||||
"Enrich": ["FromLogContext"],
|
||||
"WriteTo:Async": {
|
||||
"Name": "Async",
|
||||
"Args": {
|
||||
"configure": [
|
||||
{
|
||||
"Name": "Console",
|
||||
"Args": {
|
||||
"outputTemplate": "{Level}: {Message:lj} {Properties:j}{NewLine}{Exception}"
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "PostgreSQL",
|
||||
"Args": {
|
||||
"connectionString": "User ID=sa;Password=NvQp8s@l;Host=localhost;Port=5432;Database=Demo;",
|
||||
"tableName": "LogEntry",
|
||||
"needAutoCreateTable": false,
|
||||
"columnOptions": {
|
||||
"timestamp": { "ColumnName": "timestamp" },
|
||||
"level": { "ColumnName": "level" },
|
||||
"message": { "ColumnName": "message" },
|
||||
"messageTemplate": { "ColumnName": "message_template" },
|
||||
"exception": { "ColumnName": "exception" },
|
||||
"properties": {
|
||||
"ColumnName": "properties",
|
||||
"Store": "Json"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,6 @@ networks:
|
|||
external: false
|
||||
|
||||
volumes:
|
||||
sql:
|
||||
elastic:
|
||||
kibana:
|
||||
sql-pg:
|
||||
|
||||
services:
|
||||
|
|
@ -24,56 +21,6 @@ services:
|
|||
networks:
|
||||
- db
|
||||
restart: always
|
||||
sql:
|
||||
image: mcr.microsoft.com/mssql/server:2022-CU16-ubuntu-22.04
|
||||
user: root
|
||||
environment:
|
||||
- SA_PASSWORD=NvQp8s@l
|
||||
- ACCEPT_EULA=Y
|
||||
- MSSQL_PID=Express
|
||||
ports:
|
||||
- 1433:1433
|
||||
volumes:
|
||||
- sql:/var/opt/mssql
|
||||
networks:
|
||||
- db
|
||||
restart: always
|
||||
elastic:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:8.15.3
|
||||
volumes:
|
||||
- ./configs/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
|
||||
- elastic:/usr/share/elasticsearch/data
|
||||
ports:
|
||||
- 9200:9200
|
||||
environment:
|
||||
- xpack.security.enabled=false
|
||||
- discovery.type=single-node
|
||||
ulimits:
|
||||
memlock:
|
||||
soft: -1
|
||||
hard: -1
|
||||
nofile:
|
||||
soft: 65536
|
||||
hard: 65536
|
||||
cap_add:
|
||||
- IPC_LOCK
|
||||
networks:
|
||||
- log
|
||||
restart: always
|
||||
kibana:
|
||||
depends_on:
|
||||
- elastic
|
||||
image: docker.elastic.co/kibana/kibana:8.15.3
|
||||
volumes:
|
||||
- kibana:/usr/share/kibana/data
|
||||
ports:
|
||||
- 5601:5601
|
||||
environment:
|
||||
- XPACK_SECURITY_ENABLED=false
|
||||
- ELASTICSEARCH_HOSTS=http://elastic:9200
|
||||
networks:
|
||||
- log
|
||||
restart: always
|
||||
postgres:
|
||||
image: postgres:17
|
||||
ports:
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
name: kurs-platform
|
||||
|
||||
volumes:
|
||||
sql:
|
||||
elastic:
|
||||
kibana:
|
||||
sql-pg:
|
||||
|
||||
services:
|
||||
|
|
@ -15,17 +12,6 @@ services:
|
|||
volumes:
|
||||
- ./configs/redis.conf:/redis.conf
|
||||
command: ["redis-server", "/redis.conf"]
|
||||
sql:
|
||||
image: mcr.microsoft.com/mssql/server:2019-CU8-ubuntu-16.04
|
||||
user: root
|
||||
environment:
|
||||
- SA_PASSWORD=NvQp8s@l
|
||||
- ACCEPT_EULA=Y
|
||||
- MSSQL_PID=Express
|
||||
ports:
|
||||
- 1433:1433
|
||||
volumes:
|
||||
- sql:/var/opt/mssql
|
||||
cdn:
|
||||
image: tozlu/http-server:latest
|
||||
ports:
|
||||
|
|
@ -34,36 +20,6 @@ services:
|
|||
volumes:
|
||||
- ./data/cdn:/public
|
||||
command: "/public -c10 --cors"
|
||||
elastic:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:8.15.3
|
||||
volumes:
|
||||
- ./configs/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
|
||||
- elastic:/usr/share/elasticsearch/data
|
||||
ports:
|
||||
- 9200:9200
|
||||
environment:
|
||||
- xpack.security.enabled=false
|
||||
- discovery.type=single-node
|
||||
ulimits:
|
||||
memlock:
|
||||
soft: -1
|
||||
hard: -1
|
||||
nofile:
|
||||
soft: 65536
|
||||
hard: 65536
|
||||
cap_add:
|
||||
- IPC_LOCK
|
||||
kibana:
|
||||
depends_on:
|
||||
- elastic
|
||||
image: docker.elastic.co/kibana/kibana:8.15.3
|
||||
volumes:
|
||||
- kibana:/usr/share/kibana/data
|
||||
ports:
|
||||
- 5601:5601
|
||||
environment:
|
||||
- XPACK_SECURITY_ENABLED=false
|
||||
- ELASTICSEARCH_HOSTS=http://elastic:9200
|
||||
postgres:
|
||||
image: postgres:17
|
||||
ports:
|
||||
|
|
|
|||
Loading…
Reference in a new issue