console/web/mock/gateway/queue.js

697 lines
19 KiB
JavaScript

// Copyright (C) INFINI Labs & INFINI LIMITED.
//
// The INFINI Console is offered under the GNU Affero General Public License v3.0
// and as commercial software.
//
// For commercial licensing, contact us at:
// - Website: infinilabs.com
// - Email: hello@infini.ltd
//
// Open Source licensed under AGPL V3:
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import { off } from "@svgdotjs/svg.js";
const queueJson = {
queue: {
disk: {
c813328vi074m5vs75pg: {
depth: 0,
metadata: {
source: "dynamic",
id: "c813328vi074m5vs75pg",
name: "primary-partial-success_bulk_requests",
},
storage: {
local_usage: "10B",
local_usage_in_bytes: 10,
},
},
c81332gvi074m5vs768g: {
depth: 0,
metadata: {
source: "dynamic",
id: "c81332gvi074m5vs768g",
name: "backup-failure",
},
storage: {
local_usage: "32.5M",
local_usage_in_bytes: 34040114,
},
},
c81332gvi074m5vs7690: {
depth: 0,
metadata: {
source: "dynamic",
id: "c81332gvi074m5vs7690",
name: "request_logging",
},
storage: {
local_usage: "15.2M",
local_usage_in_bytes: 15952561,
},
},
c81332gvi074m5vs769g: {
depth: 0,
metadata: {
source: "dynamic",
id: "c81332gvi074m5vs769g",
name: "primary-failure_bulk_requests",
},
storage: {
local_usage: "10B",
local_usage_in_bytes: 10,
},
},
c81332gvi074m5vs76a0: {
depth: 0,
metadata: {
source: "dynamic",
id: "c81332gvi074m5vs76a0",
name: "primary-failure",
},
storage: {
local_usage: "3.2M",
local_usage_in_bytes: 3405255,
},
},
c81332gvi074m5vs76ag: {
depth: 0,
metadata: {
source: "dynamic",
id: "c81332gvi074m5vs76ag",
name: "backup",
},
storage: {
local_usage: "88.4M",
local_usage_in_bytes: 92703770,
},
},
c81332gvi074m5vs76eg: {
depth: 0,
metadata: {
source: "dynamic",
id: "c81332gvi074m5vs76eg",
name: "primary",
},
storage: {
local_usage: "10B",
local_usage_in_bytes: 10,
},
},
c81332ovi074m5vs76t0: {
depth: 1785821,
metadata: {
source: "dynamic",
id: "c81332ovi074m5vs76t0",
name: "backup-invalid",
},
storage: {
local_usage: "232.1M",
local_usage_in_bytes: 243362093,
},
},
c813330vi074m5vs7atg: {
depth: 29277,
metadata: {
source: "dynamic",
id: "c813330vi074m5vs7atg",
name: "backup-deadletter_requests",
},
storage: {
local_usage: "124.7M",
local_usage_in_bytes: 130790098,
},
},
c81334ovi074m5vs7h90: {
depth: 44,
metadata: {
source: "dynamic",
id: "c81334ovi074m5vs7h90",
name: "cluster_state_change",
},
storage: {
local_usage: "1.1M",
local_usage_in_bytes: 1104091,
},
},
c8137g0vi074m5vt1u30: {
consumers: [
{
group: "group-001",
id: "c8137h0vi074m5vt26r0",
name: "consumer-001",
offset: "0,323",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c8137g0vi074m5vt1u30",
name: "async_bulk-partition##backup##.kibana##0##9",
label: {
elasticsearch: "backup",
index: ".kibana",
level: "partition",
partition: 9,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,323",
storage: {
local_usage: "335B",
local_usage_in_bytes: 335,
},
synchronization: {
latest_segment: -1,
},
messages: 231,
earliest_consumer_offset: "0,323",
},
c8137g0vi074m5vt1u3g: {
consumers: [
{
group: "group-001",
id: "c8137h0vi074m5vt26qg",
name: "consumer-001",
offset: "0,649",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c8137g0vi074m5vt1u3g",
name: "async_bulk-partition##backup##.kibana##0##0",
label: {
elasticsearch: "backup",
index: ".kibana",
level: "partition",
partition: 0,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,649",
storage: {
local_usage: "661B",
local_usage_in_bytes: 661,
},
synchronization: {
latest_segment: -1,
},
messages: 232,
earliest_consumer_offset: "0,649",
},
c819qdovi074sfhfckt0: {
consumers: [
{
group: "group-001",
id: "c819qg0vi074sfhfcs1g",
name: "consumer-001",
offset: "0,312",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c819qdovi074sfhfckt0",
name: "async_bulk-partition##backup##.kibana##0##4",
label: {
elasticsearch: "backup",
index: ".kibana",
level: "partition",
partition: 4,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,312",
storage: {
local_usage: "324B",
local_usage_in_bytes: 324,
},
synchronization: {
latest_segment: -1,
},
messages: 232,
earliest_consumer_offset: "0,311",
},
c81hcjgvi074sfid6g00: {
depth: 4,
metadata: {
source: "dynamic",
id: "c81hcjgvi074sfid6g00",
name: "primary-deadletter_requests",
},
storage: {
local_usage: "48.8K",
local_usage_in_bytes: 49955,
},
},
c81hp78vi074sfieg7ag: {
consumers: [
{
group: "group-001",
id: "c81hp78vi074sfieg7gg",
name: "consumer-001",
offset: "0,1592",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c81hp78vi074sfieg7ag",
name: "async_bulk-partition##backup##.kibana##0##3",
label: {
elasticsearch: "backup",
index: ".kibana",
level: "partition",
partition: 3,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,1592",
storage: {
local_usage: "1.6K",
local_usage_in_bytes: 1605,
},
synchronization: {
latest_segment: -1,
},
},
c81j77ovi0757og02sb0: {
consumers: [
{
group: "group-001",
id: "c81j780vi0757og032q0",
name: "consumer-001",
offset: "0,26946139",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c81j77ovi0757og02sb0",
name: "async_bulk-partition##backup##filebeat-7.8.0##0##2",
label: {
elasticsearch: "backup",
index: "filebeat-7.8.0",
level: "partition",
partition: 2,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,26946139",
storage: {
local_usage: "25.7M",
local_usage_in_bytes: 26946159,
},
synchronization: {
latest_segment: -1,
},
},
c81j77ovi0757og02sbg: {
consumers: [
{
group: "group-001",
id: "c81j780vi0757og032s0",
name: "consumer-001",
offset: "0,27159139",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c81j77ovi0757og02sbg",
name: "async_bulk-partition##backup##filebeat-7.8.0##0##5",
label: {
elasticsearch: "backup",
index: "filebeat-7.8.0",
level: "partition",
partition: 5,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,27159139",
storage: {
local_usage: "25.9M",
local_usage_in_bytes: 27159159,
},
synchronization: {
latest_segment: -1,
},
},
c81j77ovi0757og02scg: {
consumers: [
{
group: "group-001",
id: "c81j780vi0757og032qg",
name: "consumer-001",
offset: "0,26953632",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c81j77ovi0757og02scg",
name: "async_bulk-partition##backup##filebeat-7.8.0##0##0",
label: {
elasticsearch: "backup",
index: "filebeat-7.8.0",
level: "partition",
partition: 0,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,26953632",
storage: {
local_usage: "25.7M",
local_usage_in_bytes: 26953652,
},
synchronization: {
latest_segment: -1,
},
},
c81j77ovi0757og02se0: {
consumers: [
{
group: "group-001",
id: "c81j780vi0757og032j0",
name: "consumer-001",
offset: "0,27067079",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c81j77ovi0757og02se0",
name: "async_bulk-partition##backup##filebeat-7.8.0##0##8",
label: {
elasticsearch: "backup",
index: "filebeat-7.8.0",
level: "partition",
partition: 8,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,27067079",
storage: {
local_usage: "25.8M",
local_usage_in_bytes: 27067099,
},
synchronization: {
latest_segment: -1,
},
},
c81j77ovi0757og02seg: {
consumers: [
{
group: "group-001",
id: "c81j7agvi0757og05mq0",
name: "consumer-001",
offset: "0,26959896",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c81j77ovi0757og02seg",
name: "async_bulk-partition##backup##filebeat-7.8.0##0##9",
label: {
elasticsearch: "backup",
index: "filebeat-7.8.0",
level: "partition",
partition: 9,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,26959896",
storage: {
local_usage: "25.7M",
local_usage_in_bytes: 26959916,
},
synchronization: {
latest_segment: -1,
},
},
c81j77ovi0757og02sf0: {
consumers: [
{
group: "group-001",
id: "c81j780vi0757og032r0",
name: "consumer-001",
offset: "0,26963081",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c81j77ovi0757og02sf0",
name: "async_bulk-partition##backup##filebeat-7.8.0##0##4",
label: {
elasticsearch: "backup",
index: "filebeat-7.8.0",
level: "partition",
partition: 4,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,26963081",
storage: {
local_usage: "25.7M",
local_usage_in_bytes: 26963101,
},
synchronization: {
latest_segment: -1,
},
},
c81j77ovi0757og02sfg: {
consumers: [
{
group: "group-001",
id: "c81j780vi0757og032rg",
name: "consumer-001",
offset: "0,27012647",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c81j77ovi0757og02sfg",
name: "async_bulk-partition##backup##filebeat-7.8.0##0##6",
label: {
elasticsearch: "backup",
index: "filebeat-7.8.0",
level: "partition",
partition: 6,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,27012647",
storage: {
local_usage: "25.8M",
local_usage_in_bytes: 27012667,
},
synchronization: {
latest_segment: -1,
},
},
c81j77ovi0757og02sg0: {
consumers: [
{
group: "group-001",
id: "c81j780vi0757og032og",
name: "consumer-001",
offset: "0,27118108",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c81j77ovi0757og02sg0",
name: "async_bulk-partition##backup##filebeat-7.8.0##0##7",
label: {
elasticsearch: "backup",
index: "filebeat-7.8.0",
level: "partition",
partition: 7,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,27118108",
storage: {
local_usage: "25.9M",
local_usage_in_bytes: 27118128,
},
synchronization: {
latest_segment: -1,
},
},
c81j77ovi0757og02sgg: {
consumers: [
{
group: "group-001",
id: "c81j7agvi0757og05mvg",
name: "consumer-001",
offset: "0,26906761",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c81j77ovi0757og02sgg",
name: "async_bulk-partition##backup##filebeat-7.8.0##0##3",
label: {
elasticsearch: "backup",
index: "filebeat-7.8.0",
level: "partition",
partition: 3,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,26906761",
storage: {
local_usage: "25.7M",
local_usage_in_bytes: 26906781,
},
synchronization: {
latest_segment: -1,
},
},
c81j77ovi0757og02sh0: {
consumers: [
{
group: "group-001",
id: "c81j780vi0757og032pg",
name: "consumer-001",
offset: "0,27009576",
source: "dynamic",
},
],
metadata: {
source: "dynamic",
id: "c81j77ovi0757og02sh0",
name: "async_bulk-partition##backup##filebeat-7.8.0##0##1",
label: {
elasticsearch: "backup",
index: "filebeat-7.8.0",
level: "partition",
partition: 1,
partition_size: 10,
shard: 0,
type: "bulk_reshuffle",
},
},
offset: "0,27009576",
storage: {
local_usage: "25.8M",
local_usage_in_bytes: 27009596,
},
synchronization: {
latest_segment: -1,
},
},
},
},
};
export default {
"GET /queue/stats": function(req, res) {
res.send(queueJson);
},
"GET /queue/:queue_id/_scroll": function(req, res) {
const queue_id = req.params.queue_id;
const size = req.query?.size || 5;
const offset = req.query?.offset || "0,0";
let result = {
context: {
next_offset: "0,649",
init_offset: "0,0",
},
messages: [
{
message:
'{"index":{"_id":"application_usage_daily:monitoring:2022-02-08","_index":".kibana"}}\n{"application_usage_daily":{"appId":"monitoring","timestamp":"2022-02-08T00:00:00.000Z","minutesOnScreen":31.762333333333345,"numberOfClicks":28},"type":"application_usage_daily","references":[],"updated_at":"2022-02-08T09:11:26.968Z"}\n',
offset: "0,0",
size: 325,
},
{
message:
'{"index":{"_id":"application_usage_daily:monitoring:2022-02-08","_index":".kibana"}}\n{"application_usage_daily":{"appId":"monitoring","timestamp":"2022-02-08T00:00:00.000Z","minutesOnScreen":32.46760000000002,"numberOfClicks":32},"type":"application_usage_daily","references":[],"updated_at":"2022-02-08T16:41:26.977Z"}\n',
offset: "0,325",
size: 324,
},
],
timeout: false,
};
// if (offset === "0,649") {
// result = {
// "error":"no data"
// }
// }
res.send(result);
},
"GET /queue/:queue_id/consumer/:consumer_id/offset": function(req, res) {
const result = {
found: true,
result: "91,10080429",
};
res.send(result);
},
// curl -XPUT http://localhost:2900/queue/c82987ai4h914j855k4g/consumer/c82989ii4h914j856020/offset\?offset\=0,0
"PUT /queue/:queue_id/consumer/:consumer_id/offset": function(req, res) {
const result = {
acknowledged: true,
};
res.send(result);
},
"DELETE /queue/:queue_id/consumer/:consumer_id": function(req, res) {
// 200 response
const result = {
result: "deleted",
};
res.send(result);
// 404 response
// const result = {
// result: "not_founnd",
// };
// res.status(404).send(result);
},
};