Skip to content

Commit 1570f22

Browse files
authored
Merge pull request #228 from suahlingo/refactor/java-module
Refactor/java module
2 parents e94d811 + c19383b commit 1570f22

File tree

6 files changed

+50
-15
lines changed

6 files changed

+50
-15
lines changed

java-module/grafana/run.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,17 @@ RESPONSE=$(curl -s -b ~/grafana-cookie -XGET \
177177
-H 'Accept: */*' \
178178
-H 'Content-Type: application/json' \
179179
-H 'Origin: http://127.0.0.1:3000')
180-
DATA_SOURCE_INFLUXDB_UID=$(echo $RESPONSE | sed -n 's/.*"uid":"\([^"]*\)".*/\1/p')
181-
echo DATA_SOURCE_INFLUXDB_UID=$DATA_SOURCE_INFLUXDB_UID >> ~/env.grafana
180+
INFLUX1_UID=$(echo $RESPONSE | sed -n 's/.*"uid":"\([^"]*\)".*/\1/p')
181+
echo "INFLUX1_UID=$INFLUX1_UID" >> ~/env.grafana
182+
183+
184+
RESPONSE=$(curl -s -b ~/grafana-cookie -XGET \
185+
"http://127.0.0.1:3000/api/datasources/name/InfluxDB-2" \
186+
-H 'Accept: */*' \
187+
-H 'Content-Type: application/json' \
188+
-H 'Origin: http://127.0.0.1:3000')
189+
INFLUX2_UID=$(echo $RESPONSE | sed -n 's/.*"uid":"\([^"]*\)".*/\1/p')
190+
echo "INFLUX2_UID=$INFLUX2_UID" >> ~/env.grafana
182191

183192
echo "[*] Deleting cookie..."
184193
rm -f ~/grafana-cookie

java-module/mc-o11y-manager/src/test/java/com/mcmp/o11ymanager/manager/controller/InfluxDBControllerTest.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,12 @@ void getMetricsByNsIdAndMciId() throws Exception {
224224
"fields[].field",
225225
"Field name (e.g., usage_idle)")
226226
.optional(),
227-
fieldArray("conditions", "List of condition filters"),
228-
fieldString("conditions[].key", "Condition key (e.g., cpu)")
227+
fieldArray(
228+
"conditions",
229+
"List of condition filters (excluding default keys: ns_id, mci_id)"),
230+
fieldString(
231+
"conditions[].key",
232+
"Condition key (e.g., cpu) — omit ns_id, mci_id since they are added by default")
229233
.optional(),
230234
fieldString(
231235
"conditions[].value",
@@ -314,8 +318,12 @@ void getMetricsByVMId() throws Exception {
314318
"fields[].field",
315319
"Field name (e.g., usage_idle)")
316320
.optional(),
317-
fieldArray("conditions", "List of condition filters"),
318-
fieldString("conditions[].key", "Condition key (e.g., cpu)")
321+
fieldArray(
322+
"conditions",
323+
"List of condition filters (excluding default keys: ns_id, mci_id, vm_id)"),
324+
fieldString(
325+
"conditions[].key",
326+
"Condition key (e.g., cpu) — omit ns_id, mci_id, vm_id since they are added by default")
319327
.optional(),
320328
fieldString(
321329
"conditions[].value",

java-module/slack_user_guide.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,14 @@ to receive mc-o11y events and alarms within a Slack workspace.
4747

4848
## Step 6: Use Token
4949

50-
1. After that, when using the mc-o11y event/alarm slack user registration API(POST /api/o11y/trigger/policy/{policySeq}/alert/slack), you can enter the pre-generated **Bot User OAuth token**.
50+
1. After that, when using the mc-o11y event/alarm slack user registration API(POST /api/o11y/trigger/policy/{id}/channel, you can enter the pre-generated **Bot User OAuth token**.
51+
2. This token is required for mc-o11y to send messages through your Slack bot. If the Slack Bot User OAuth Token is changed or reissued, make sure to **update the token value in the .env file of the mc-observability-manager** accordingly.
52+
53+
## Step 7: Use Channel ID
54+
55+
1. When sending messages to Slack via the API, you must use the Channel ID of a public channel where the app has been added.
56+
The Channel ID can be found in the Slack channel URL.
57+
58+
2. You need to copy this value and use it as the value of the **recipients** field.
59+
https://app.slack.com/client/<WORKSPACE_ID>/**<CHANNEL_ID>**
60+

java-module/swagger/MC-Observability Swagger(OpenAPI 2.0).yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,14 +1674,14 @@ definitions:
16741674
description: Result limit count
16751675
group_by:
16761676
type: array
1677-
description: "List of group-by fields, for example: ns_id, mci_id"
1677+
description: "List of group-by fields (e.g., vm_id)"
16781678
items: {}
16791679
range:
16801680
type: string
16811681
description: "Query range (e.g., 1h)"
16821682
conditions:
16831683
type: array
1684-
description: List of condition filters
1684+
description: "List of condition filters (excluding default keys: ns_id, mci_id)"
16851685
items:
16861686
type: object
16871687
properties:
@@ -1690,7 +1690,8 @@ definitions:
16901690
description: "Condition value (e.g., cpu-total)"
16911691
key:
16921692
type: string
1693-
description: "Condition key (e.g., cpu)"
1693+
description: "Condition key (e.g., cpu) — omit ns_id, mci_id since they\
1694+
\ are added by default"
16941695
fields:
16951696
type: array
16961697
description: List of fields to query

java-module/swagger/MC-Observability Swagger(OpenAPI 3.0).yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,16 +1481,19 @@ components:
14811481
description: "Query range (e.g., 1h)"
14821482
conditions:
14831483
type: array
1484-
description: List of condition filters
1484+
description: "List of group-by fields (e.g., vm_id)"
14851485
items:
14861486
type: object
14871487
properties:
14881488
value:
14891489
type: string
14901490
description: "Condition value (e.g., cpu-total)"
1491+
nullable: true
14911492
key:
14921493
type: string
1493-
description: "Condition key (e.g., cpu)"
1494+
description: "Condition key (e.g., cpu) — omit ns_id, mci_id since\
1495+
\ they are added by default"
1496+
nullable: true
14941497
fields:
14951498
type: array
14961499
description: List of fields to query

java-module/swagger/swagger.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,23 +2647,27 @@ definitions:
26472647
description: Result limit count
26482648
group_by:
26492649
type: array
2650-
description: "List of group-by fields, for example: ns_id, mci_id"
2650+
description: "List of group-by fields (e.g., vm_id)"
26512651
items: { }
26522652
range:
26532653
type: string
26542654
description: "Query range (e.g., 1h)"
26552655
conditions:
26562656
type: array
2657-
description: List of condition filters
2657+
description: "List of condition filters (excluding default keys: ns_id,\
2658+
\ mci_id, \ vm_id)"
26582659
items:
26592660
type: object
26602661
properties:
26612662
value:
26622663
type: string
26632664
description: "Condition value (e.g., cpu-total)"
2665+
nullable: true
26642666
key:
26652667
type: string
2666-
description: "Condition key (e.g., cpu)"
2668+
description: "Condition key (e.g., cpu) — omit ns_id, mci_id or vm_id since\
2669+
\ they are added by default"
2670+
nullable: true
26672671
fields:
26682672
type: array
26692673
description: List of fields to query

0 commit comments

Comments
 (0)