Skip to content

Commit

Permalink
New - Ajout de monitoring sur les endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
noelmugnier committed Nov 25, 2020
1 parent cc231f8 commit 9eacab4
Show file tree
Hide file tree
Showing 12 changed files with 255 additions and 3 deletions.
15 changes: 15 additions & 0 deletions Docker/cachet-monitor/DockerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM alpine

ENV VERSION=v3.0

ADD https://github.com/CastawayLabs/cachet-monitor/releases/download/${VERSION}/cachet_monitor_linux_amd64 /usr/bin/cachet-monitor

RUN apk add --no-cache --virtual ca-certificates \
&& apk add --no-cache --virtual tzdata \
&& chmod 755 /usr/bin/cachet-monitor

COPY docker-entrypoint.sh /

ENTRYPOINT [ "/docker-entrypoint.sh" ]

CMD [ "cachet-monitor","-c", "/etc/cachet-monitor.yaml"]
91 changes: 91 additions & 0 deletions Docker/cachet-monitor/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
api:
url: https://status.sheaft.com/api/v1
token: ######
insecure: false
date_format: 02/01/2006 15:04:05 MST
monitors:
- name: graphql
target: https://api.sheaft.com/health/livez
strict: true
method: GET
component_id: 3
metric_id: 1
template:
investigating:
subject: "{{ .Monitor.Name }} - {{ .SystemName }}"
message: "{{ .Monitor.Name }} check **failed** (server time: {{ .now }})\n\n{{ .FailReason }}"
fixed:
subject: "GraphQL Fixed"
interval: 60
timeout: 10
threshold: 80
expected_status_code: 200
expected_body: "OK"
- name: jobs
target: https://jobs.sheaft.com/health/livez
strict: true
method: GET
component_id: 4
metric_id: 2
template:
investigating:
subject: "{{ .Monitor.Name }} - {{ .SystemName }}"
message: "{{ .Monitor.Name }} check **failed** (server time: {{ .now }})\n\n{{ .FailReason }}"
fixed:
subject: "Jobs Fixed"
interval: 60
timeout: 10
threshold: 80
expected_status_code: 200
expected_body: "OK"
- name: payment
target: https://payment.sheaft.com/health/livez
strict: true
method: GET
component_id: 5
metric_id: 3
template:
investigating:
subject: "{{ .Monitor.Name }} - {{ .SystemName }}"
message: "{{ .Monitor.Name }} check **failed** (server time: {{ .now }})\n\n{{ .FailReason }}"
fixed:
subject: "Payment Fixed"
interval: 60
timeout: 10
threshold: 80
expected_status_code: 200
expected_body: "OK"
- name: signalr
target: https://signalr.sheaft.com/health/livez
strict: true
method: GET
component_id: 6
metric_id: 4
template:
investigating:
subject: "{{ .Monitor.Name }} - {{ .SystemName }}"
message: "{{ .Monitor.Name }} check **failed** (server time: {{ .now }})\n\n{{ .FailReason }}"
fixed:
subject: "Signalr Fixed"
interval: 60
timeout: 10
threshold: 80
expected_status_code: 200
expected_body: "OK"
- name: identity
target: https://auth.sheaft.com/health/livez
strict: true
method: GET
component_id: 13
metric_id: 5
template:
investigating:
subject: "{{ .Monitor.Name }} - {{ .SystemName }}"
message: "{{ .Monitor.Name }} check **failed** (server time: {{ .now }})\n\n{{ .FailReason }}"
fixed:
subject: "Identity Fixed"
interval: 60
timeout: 10
threshold: 80
expected_status_code: 200
expected_body: "OK"
13 changes: 13 additions & 0 deletions Docker/cachet-monitor/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh
set -e


if [ -n "$CONFIG" ]; then
echo "Found configuration variable, will write it to /etc/cachet-monitor.yaml"
echo "$CONFIG" > /etc/cachet-monitor.yaml
elif [ ! -f /etc/cachet-monitor.yaml ]; then
echo "Please provide configuration in CONFIG variable or write it in /etc/cachet-monitor.yaml"
exit 1
fi

exec "$@"
43 changes: 43 additions & 0 deletions Docker/sheaft-status/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: '3'
services:
sql:
image: mysql:5.7
restart: always
environment:
- MYSQL_ROOT_PASSWORD=#########
- MYSQL_USER=user_sa
- MYSQL_PASSWORD=#########
- MYSQL_DATABASE=cachethq
volumes:
- sheaftstatus:/var/lib/mysql
cachet:
image: sheaft/sheaft.cachethq:latest
ports:
- 8000:8080
environment:
- DB_DRIVER=mysql
- DB_HOST=sql
- DB_DATABASE=cachethq
- DB_USERNAME=user_sa
- DB_PASSWORD==#########
- DB_PREFIX=chq_
- APP_KEY=base64:D9XPB/5oa1fi7RfcWdkZGtqx90JHdJXCfS/J7g0ZnZ4=
- APP_LOG=errorlog
- APP_ENV=production
- APP_DEBUG=true
- APP_URL=https://status.sheaft.com
- QUEUE_DRIVER=sync
- MAIL_DRIVER=SMTP
- MAIL_HOST==#########
- MAIL_PORT=25
- MAIL_USERNAME=#########
- MAIL_PASSWORD==#########
- [email protected]
- MAIL_NAME="Monitoring Sheaft"
- MAIL_ENCRYPTION=tls
restart: always
monitoring:
image: sheaft/sheaft.cachetmonitor:latest
restart: always
volumes:
- ${WEBAPP_STORAGE_HOME}/site/wwwroot/config.yml:/etc/cachet-monitor.yaml
17 changes: 17 additions & 0 deletions Sheaft.Web.Api/Controllers/HealthController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;

namespace Sheaft.Web.Api.Controllers
{
public class HealthController : Controller
{
public IActionResult Livez()
{
return Ok("OK");
}

public IActionResult Readyz()
{
return Ok("OK");
}
}
}
2 changes: 1 addition & 1 deletion Sheaft.Web.Api/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Sheaft.Web.Api.Controllers
{
public class HomeController : ControllerBase
public class HomeController : Controller
{
public IActionResult Index()
{
Expand Down
2 changes: 1 addition & 1 deletion Sheaft.Web.Api/Controllers/UploadController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Sheaft.Web.Api.Controllers
[Authorize]
[ApiController]
[Route("upload")]
public class UploadController : ControllerBase
public class UploadController : Controller
{
private readonly ISheaftMediatr _mediatr;
private readonly IHttpContextAccessor _httpContextAccessor;
Expand Down
7 changes: 6 additions & 1 deletion Sheaft.Web.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,12 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IConfigu

app.UseIpRateLimiting();

app.UseMvc();
app.UseMvc(endpoints =>
{
endpoints.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});

app.UseWebSockets();
app.UseGraphQL("/graphql");
Expand Down
17 changes: 17 additions & 0 deletions Sheaft.Web.Jobs/Controllers/HealthController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;

namespace Sheaft.Web.Jobs.Controllers
{
public class HealthController : Controller
{
public IActionResult Livez()
{
return Ok("OK");
}

public IActionResult Readyz()
{
return Ok("OK");
}
}
}
17 changes: 17 additions & 0 deletions Sheaft.Web.Manage/Controllers/HealthController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;

namespace Sheaft.Web.Manage.Controllers
{
public class HealthController : Controller
{
public IActionResult Livez()
{
return Ok("OK");
}

public IActionResult Readyz()
{
return Ok("OK");
}
}
}
17 changes: 17 additions & 0 deletions Sheaft.Web.Payment/Controllers/HealthController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;

namespace Sheaft.Web.Payment.Controllers
{
public class HealthController : Controller
{
public IActionResult Livez()
{
return Ok("OK");
}

public IActionResult Readyz()
{
return Ok("OK");
}
}
}
17 changes: 17 additions & 0 deletions Sheaft.Web.Signalr/Controllers/HealthController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;

namespace Sheaft.Web.Signalr.Controllers
{
public class HealthController : Controller
{
public IActionResult Livez()
{
return Ok("OK");
}

public IActionResult Readyz()
{
return Ok("OK");
}
}
}

0 comments on commit 9eacab4

Please sign in to comment.