Skip to content

Commit

Permalink
feat: add loki-logger plugin support
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdeadbeer committed Aug 6, 2023
1 parent e0290c8 commit f17de1f
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 0 deletions.
131 changes: 131 additions & 0 deletions api/conf/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6092,6 +6092,137 @@
},
"version": 0.1
},
"loki-logger": {
"metadata_schema": {
"properties": {
"log_format": {
"default": {
"@timestamp": "$time_iso8601",
"client_ip": "$remote_addr",
"host": "$host"
},
"type": "object"
}
},
"type": "object"
},
"priority": 414,
"schema": {
"$comment":"this is a mark for our injected plugin schema",
"properties": {
"_meta": {
"properties": {
"disable": {
"type": "boolean"
},
"error_response": {
"oneOf": [
{
"type": "string"
},
{
"type": "object"
}
]
},
"filter": {
"description": "filter determines whether the plugin needs to be executed at runtime",
"type": "array"
},
"priority": {
"description": "priority of plugins by customized order",
"type": "integer"
}
},
"type": "object"
},
"endpoint_addrs": {
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"pattern": "[=[^[^\\\/]+:\\\/\\\/([\\da-zA-Z.-]+|\\[[\\da-fA-F:]+\\])(:\\d+)?]=]"
}
},
"endpoint_uri": {
"type": "string",
"minLength": 1,
"default": "/loki/api/v1/push"
},
"tenant_id": {
"type": "string",
"default": "fake"
},
"log_labels": {
"type": "object",
"patternProperties": {
".*": {
"type": "string",
"minLength": 1
}
},
"default": {
"job": "apisix"
}
},
"ssl_verify": {
"type": "boolean",
"default": false
},
"timeout": {
"type": "integer",
"minimum": 1,
"maximum": 60000,
"default": 3000,
"description": "timeout in milliseconds"
},
"keepalive": {
"type": "boolean",
"default": true
},
"keepalive_timeout": {
"type": "integer",
"minimum": 1000,
"default": 60000
},
"keepalive_pool": {
"type": "integer",
"minimum": 1,
"default": 5
},
"log_format": {
"type": "object"
},
"include_req_body": {
"type": "boolean",
"default": false
},
"include_req_body_expr": {
"type": "array",
"minItems": 1,
"items": {
"type": "array"
}
},
"include_resp_body": {
"type": "boolean",
"default": false
},
"include_resp_body_expr": {
"type": "array",
"minItems": 1,
"items": {
"type": "array"
}
}
},
"required": [
"endpoint_addrs"
],
"type": "object"
},
"version": 0.1
},
"ip-restriction": {
"priority": 3000,
"schema": {
Expand Down
6 changes: 6 additions & 0 deletions web/src/components/Plugin/Models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ export const httploggerModel = editor.createModel(
Uri.parse('file:http-logger'),
);

export const lokiloggerModel = editor.createModel(
modelCode.lokilogger,
'json',
Uri.parse('file:loki-logger'),
);

export const kafkaloggerModel = editor.createModel(
modelCode.kafkalogger,
'json',
Expand Down
4 changes: 4 additions & 0 deletions web/src/components/Plugin/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const PLUGIN_ICON_LIST: Record<string, any> = {
'udp-logger': <IconFont name="iconudp-logger" />,
'error-log-logger': <IconFont name="iconerror-logger" />,
'http-logger': <IconFont name="iconhttp-logger" />,
'loki-logger': <IconFont name="iconloki-logger" />,
'request-id': <IconFont name="iconrequest-id" />,
'sls-logger': <IconFont name="iconsls-logger" />,
syslog: <IconFont name="iconsys-logger" />,
Expand Down Expand Up @@ -173,6 +174,9 @@ export const PLUGIN_LIST = {
'http-logger': {
type: PluginType.observability,
},
'loki-logger': {
type: PluginType.observability,
},
'ip-restriction': {
type: PluginType.security,
},
Expand Down
5 changes: 5 additions & 0 deletions web/src/components/Plugin/modelCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ export const httplogger = `{
}
`;

export const lokilogger = `{
"endpoint_addrs": []
}
`;

export const kafkalogger = `{
"broker_list" :
"kafka_topic" :
Expand Down

0 comments on commit f17de1f

Please sign in to comment.