events: migrate SystemTasks to DB (#8159)
* events: migrate system tasks to save in DB Signed-off-by: Jens Langhammer <jens@goauthentik.io> * prefill in app startup Signed-off-by: Jens Langhammer <jens@goauthentik.io> * cleanup api Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update web Signed-off-by: Jens Langhammer <jens@goauthentik.io> * use string for status Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix enum Signed-off-by: Jens Langhammer <jens@goauthentik.io> * save start and end directly in timestamp from default_timer() Signed-off-by: Jens Langhammer <jens@goauthentik.io> * improve metrics Signed-off-by: Jens Langhammer <jens@goauthentik.io> * lint Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * rename globally to system task Signed-off-by: Jens Langhammer <jens@goauthentik.io> * recreate migrations, better denote anonymous user Signed-off-by: Jens Langhammer <jens@goauthentik.io> * events: lookup actual django app instead of using module path, fallback to module path Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix logger call Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
		| @ -1,8 +1,7 @@ | ||||
| import { EventGeo } from "@goauthentik/admin/events/utils"; | ||||
| import { EventGeo, EventUser } from "@goauthentik/admin/events/utils"; | ||||
| import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; | ||||
| import { EventWithContext } from "@goauthentik/common/events"; | ||||
| import { actionToLabel } from "@goauthentik/common/labels"; | ||||
| import { truncate } from "@goauthentik/common/utils"; | ||||
| import "@goauthentik/components/ak-event-info"; | ||||
| import "@goauthentik/elements/Tabs"; | ||||
| import "@goauthentik/elements/buttons/Dropdown"; | ||||
| @ -11,7 +10,7 @@ import "@goauthentik/elements/buttons/SpinnerButton"; | ||||
| import { PaginatedResponse } from "@goauthentik/elements/table/Table"; | ||||
| import { Table, TableColumn } from "@goauthentik/elements/table/Table"; | ||||
|  | ||||
| import { msg, str } from "@lit/localize"; | ||||
| import { msg } from "@lit/localize"; | ||||
| import { CSSResult, TemplateResult, css, html } from "lit"; | ||||
| import { customElement, property } from "lit/decorators.js"; | ||||
|  | ||||
| @ -71,20 +70,7 @@ export class RecentEventsCard extends Table<Event> { | ||||
|         return [ | ||||
|             html`<div><a href="${`#/events/log/${item.pk}`}">${actionToLabel(item.action)}</a></div> | ||||
|                 <small>${item.app}</small>`, | ||||
|             item.user?.username | ||||
|                 ? html`<div> | ||||
|                           <a href="#/identity/users/${item.user.pk}" | ||||
|                               >${truncate(item.user?.username, 15)}</a | ||||
|                           > | ||||
|                       </div> | ||||
|                       ${item.user.on_behalf_of | ||||
|                           ? html`<small> | ||||
|                                 <a href="#/identity/users/${item.user.on_behalf_of.pk}" | ||||
|                                     >${msg(str`On behalf of ${item.user.on_behalf_of.username}`)}</a | ||||
|                                 > | ||||
|                             </small>` | ||||
|                           : html``}` | ||||
|                 : html`-`, | ||||
|             EventUser(item), | ||||
|             html`<span>${item.created?.toLocaleString()}</span>`, | ||||
|             html` <div>${item.clientIp || msg("-")}</div> | ||||
|                 <small>${EventGeo(item)}</small>`, | ||||
|  | ||||
| @ -6,7 +6,7 @@ import { ChartData, ChartOptions } from "chart.js"; | ||||
| import { msg } from "@lit/localize"; | ||||
| import { customElement } from "lit/decorators.js"; | ||||
|  | ||||
| import { ProvidersApi, SourcesApi, TaskStatusEnum } from "@goauthentik/api"; | ||||
| import { ProvidersApi, SourcesApi, SystemTaskStatusEnum } from "@goauthentik/api"; | ||||
|  | ||||
| export interface SyncStatus { | ||||
|     healthy: number; | ||||
| @ -49,12 +49,12 @@ export class LDAPSyncStatusChart extends AKChart<SyncStatus[]> { | ||||
|                     }); | ||||
|  | ||||
|                     health.tasks.forEach((task) => { | ||||
|                         if (task.status !== TaskStatusEnum.Successful) { | ||||
|                         if (task.status !== SystemTaskStatusEnum.Successful) { | ||||
|                             metrics.failed += 1; | ||||
|                         } | ||||
|                         const now = new Date().getTime(); | ||||
|                         const maxDelta = 3600000; // 1 hour | ||||
|                         if (!health || now - task.taskFinishTimestamp.getTime() > maxDelta) { | ||||
|                         if (!health || now - task.finishTimestamp.getTime() > maxDelta) { | ||||
|                             metrics.unsynced += 1; | ||||
|                         } else { | ||||
|                             metrics.healthy += 1; | ||||
| @ -94,12 +94,12 @@ export class LDAPSyncStatusChart extends AKChart<SyncStatus[]> { | ||||
|                         id: element.pk, | ||||
|                     }); | ||||
|                     health.tasks.forEach((task) => { | ||||
|                         if (task.status !== TaskStatusEnum.Successful) { | ||||
|                         if (task.status !== SystemTaskStatusEnum.Successful) { | ||||
|                             sourceKey = "failed"; | ||||
|                         } | ||||
|                         const now = new Date().getTime(); | ||||
|                         const maxDelta = 3600000; // 1 hour | ||||
|                         if (!health || now - task.taskFinishTimestamp.getTime() > maxDelta) { | ||||
|                         if (!health || now - task.finishTimestamp.getTime() > maxDelta) { | ||||
|                             sourceKey = "unsynced"; | ||||
|                         } | ||||
|                     }); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Jens L
					Jens L