create-junando-app 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +23 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +204 -0
- package/package.json +38 -0
- package/template/README.md +139 -0
- package/template/app/.env.example +29 -0
- package/template/app/.nvmrc +1 -0
- package/template/app/Dockerfile +7 -0
- package/template/app/_gitignore +2 -0
- package/template/app/package.json +17 -0
- package/template/app/src/server.js +80 -0
- package/template/docker/alertmanager/alertmanager.yml +11 -0
- package/template/docker/loki/loki-config.yml +25 -0
- package/template/docker/prometheus/prometheus.yml +16 -0
- package/template/docker/prometheus/rules.yml +17 -0
- package/template/docker-compose.yml +72 -0
- package/template/scripts/simulate.sh +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# create-junando-app
|
|
2
|
+
|
|
3
|
+
Scaffold a new [Junando](https://github.com/GerMoren/junando) alerting app in seconds. This package copies the `express-end-to-end` template into a new directory and wires up your project name — no configuration files to touch, no boilerplate to delete.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm create junando-app my-app
|
|
9
|
+
# or
|
|
10
|
+
npx create-junando-app my-app
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
After scaffolding:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cd my-app/app
|
|
17
|
+
cp .env.example .env # edit with your LLM/Slack keys
|
|
18
|
+
pnpm dev
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## What's next
|
|
22
|
+
|
|
23
|
+
See `my-app/app/README.md` (or the [example README](../../examples/express-end-to-end/README.md)) for a full walkthrough of what gets scaffolded, environment variables, and how to connect your LLM and Slack integrations.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import { existsSync, readFileSync } from "fs";
|
|
5
|
+
import { basename } from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
|
|
8
|
+
// src/helpers/parse-args.ts
|
|
9
|
+
function parseArgs(argv) {
|
|
10
|
+
const args = argv.slice(2);
|
|
11
|
+
let projectName2;
|
|
12
|
+
let help = false;
|
|
13
|
+
let version = false;
|
|
14
|
+
let unknownFlag;
|
|
15
|
+
for (const arg of args) {
|
|
16
|
+
if (arg === "--help" || arg === "-h") {
|
|
17
|
+
help = true;
|
|
18
|
+
} else if (arg === "--version" || arg === "-v") {
|
|
19
|
+
version = true;
|
|
20
|
+
} else if (arg.startsWith("-")) {
|
|
21
|
+
unknownFlag = arg;
|
|
22
|
+
} else if (projectName2 === void 0) {
|
|
23
|
+
projectName2 = arg;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return { projectName: projectName2, help, version, unknownFlag };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/helpers/validate-name.ts
|
|
30
|
+
function isValidProjectName(name) {
|
|
31
|
+
return /^[a-z0-9][a-z0-9._-]*$/i.test(name);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/scaffold.ts
|
|
35
|
+
import { cp, readdir, rename, access, copyFile } from "fs/promises";
|
|
36
|
+
import { join } from "path";
|
|
37
|
+
import { spawn } from "child_process";
|
|
38
|
+
|
|
39
|
+
// src/helpers/rewrite-package-json.ts
|
|
40
|
+
import { readFile, writeFile } from "fs/promises";
|
|
41
|
+
async function rewritePackageJson(path, mutate) {
|
|
42
|
+
const raw = await readFile(path, "utf-8");
|
|
43
|
+
const pkg2 = JSON.parse(raw);
|
|
44
|
+
const updated = mutate(pkg2);
|
|
45
|
+
await writeFile(path, JSON.stringify(updated, null, 2) + "\n", "utf-8");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/scaffold.ts
|
|
49
|
+
async function scaffold({
|
|
50
|
+
targetDir: targetDir2,
|
|
51
|
+
projectName: projectName2,
|
|
52
|
+
templateDir: templateDir2,
|
|
53
|
+
skipInstall = false
|
|
54
|
+
}) {
|
|
55
|
+
let entries = [];
|
|
56
|
+
try {
|
|
57
|
+
entries = await readdir(targetDir2);
|
|
58
|
+
} catch (err) {
|
|
59
|
+
const code = err.code;
|
|
60
|
+
if (code !== "ENOENT") {
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (entries.length > 0) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`Target directory "${targetDir2}" already exists and is non-empty. Remove it first or choose a different name.`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
await cp(templateDir2, targetDir2, { recursive: true });
|
|
70
|
+
const renamedGitignore = join(targetDir2, "app", "_gitignore");
|
|
71
|
+
try {
|
|
72
|
+
await access(renamedGitignore);
|
|
73
|
+
await rename(renamedGitignore, join(targetDir2, "app", ".gitignore"));
|
|
74
|
+
} catch {
|
|
75
|
+
}
|
|
76
|
+
const envExample = join(targetDir2, "app", ".env.example");
|
|
77
|
+
const envFile = join(targetDir2, "app", ".env");
|
|
78
|
+
try {
|
|
79
|
+
await access(envExample);
|
|
80
|
+
let envExists = false;
|
|
81
|
+
try {
|
|
82
|
+
await access(envFile);
|
|
83
|
+
envExists = true;
|
|
84
|
+
} catch {
|
|
85
|
+
}
|
|
86
|
+
if (!envExists) {
|
|
87
|
+
await copyFile(envExample, envFile);
|
|
88
|
+
}
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
const pkgPath = join(targetDir2, "app", "package.json");
|
|
92
|
+
await rewritePackageJson(pkgPath, (pkg2) => ({ ...pkg2, name: projectName2 }));
|
|
93
|
+
if (!skipInstall) {
|
|
94
|
+
await runPnpmInstall(join(targetDir2, "app"));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function runPnpmInstall(cwd) {
|
|
98
|
+
return new Promise((resolve, reject) => {
|
|
99
|
+
const child = spawn("pnpm", ["install"], { cwd, stdio: "inherit", shell: false });
|
|
100
|
+
child.on("error", (err) => {
|
|
101
|
+
if (err.code === "ENOENT") {
|
|
102
|
+
reject(new Error("pnpm not found on PATH. Install pnpm (https://pnpm.io/installation) and try again."));
|
|
103
|
+
} else {
|
|
104
|
+
reject(err);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
child.on("close", (code) => {
|
|
108
|
+
if (code === 0) {
|
|
109
|
+
resolve();
|
|
110
|
+
} else {
|
|
111
|
+
reject(new Error(`pnpm install exited with code ${String(code)}`));
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/helpers/next-steps.ts
|
|
118
|
+
var RESET = "\x1B[0m";
|
|
119
|
+
var BOLD = "\x1B[1m";
|
|
120
|
+
var GREEN = "\x1B[32m";
|
|
121
|
+
var CYAN = "\x1B[36m";
|
|
122
|
+
function buildNextStepsMessage(targetDir2) {
|
|
123
|
+
return [
|
|
124
|
+
"",
|
|
125
|
+
`${GREEN}${BOLD}\u2714 Scaffolded ${targetDir2} successfully!${RESET}`,
|
|
126
|
+
"",
|
|
127
|
+
`${BOLD}Next steps:${RESET}`,
|
|
128
|
+
` ${CYAN}cd ${targetDir2}/app${RESET}`,
|
|
129
|
+
` ${CYAN}pnpm dev${RESET}`,
|
|
130
|
+
"",
|
|
131
|
+
`Your ${CYAN}.env${RESET} was created from ${CYAN}.env.example${RESET} with placeholder values.`,
|
|
132
|
+
`Edit it with your real LLM/Slack keys when you wire the full pipeline.`,
|
|
133
|
+
"",
|
|
134
|
+
`See ${targetDir2}/app/README.md for more details.`,
|
|
135
|
+
""
|
|
136
|
+
].join("\n");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/cli.ts
|
|
140
|
+
var pkgUrl = new URL("../package.json", import.meta.url);
|
|
141
|
+
var pkg = JSON.parse(readFileSync(fileURLToPath(pkgUrl), "utf8"));
|
|
142
|
+
var VERSION = pkg.version;
|
|
143
|
+
var USAGE = `
|
|
144
|
+
Usage:
|
|
145
|
+
pnpm create junando-app <project-name>
|
|
146
|
+
npx create-junando-app <project-name>
|
|
147
|
+
|
|
148
|
+
Arguments:
|
|
149
|
+
project-name Name of the new project directory
|
|
150
|
+
|
|
151
|
+
Options:
|
|
152
|
+
--help, -h Show this help message
|
|
153
|
+
--version, -v Show version number
|
|
154
|
+
`.trim();
|
|
155
|
+
var RED = "\x1B[31m";
|
|
156
|
+
var RESET2 = "\x1B[0m";
|
|
157
|
+
function die(msg) {
|
|
158
|
+
process.stderr.write(`${RED}Error: ${msg}${RESET2}
|
|
159
|
+
`);
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
var parsed = parseArgs(process.argv);
|
|
163
|
+
if (parsed.help) {
|
|
164
|
+
console.log(USAGE);
|
|
165
|
+
process.exit(0);
|
|
166
|
+
}
|
|
167
|
+
if (parsed.version) {
|
|
168
|
+
console.log(VERSION);
|
|
169
|
+
process.exit(0);
|
|
170
|
+
}
|
|
171
|
+
if (parsed.unknownFlag !== void 0) {
|
|
172
|
+
die(`Unknown flag: ${parsed.unknownFlag}
|
|
173
|
+
|
|
174
|
+
${USAGE}`);
|
|
175
|
+
}
|
|
176
|
+
if (parsed.projectName === void 0) {
|
|
177
|
+
process.stderr.write(USAGE + "\n");
|
|
178
|
+
process.exit(1);
|
|
179
|
+
}
|
|
180
|
+
var targetDir = parsed.projectName;
|
|
181
|
+
var projectName = basename(targetDir);
|
|
182
|
+
if (targetDir.split(/[\\/]/).includes("..")) {
|
|
183
|
+
die(`Target path "${targetDir}" must not contain ".." segments.`);
|
|
184
|
+
}
|
|
185
|
+
if (!isValidProjectName(projectName)) {
|
|
186
|
+
die(
|
|
187
|
+
`Invalid project name "${projectName}". Use letters, digits, dots, hyphens, or underscores; must start with a letter or digit.`
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
var templateDirUrl = new URL("../template/", import.meta.url);
|
|
191
|
+
var templateDir = fileURLToPath(templateDirUrl);
|
|
192
|
+
if (!existsSync(templateDir)) {
|
|
193
|
+
die(
|
|
194
|
+
`Template directory not found at ${templateDir}. This is likely a broken install \u2014 try reinstalling create-junando-app.`
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
(async () => {
|
|
198
|
+
try {
|
|
199
|
+
await scaffold({ targetDir, projectName, templateDir });
|
|
200
|
+
process.stdout.write(buildNextStepsMessage(targetDir));
|
|
201
|
+
} catch (err) {
|
|
202
|
+
die(err instanceof Error ? err.message : String(err));
|
|
203
|
+
}
|
|
204
|
+
})();
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-junando-app",
|
|
3
|
+
"version": "0.7.3",
|
|
4
|
+
"description": "Scaffold a new Junando alerting app from the express-end-to-end template",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-junando-app": "./dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/cli.js",
|
|
11
|
+
"types": "./dist/cli.d.ts",
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"template",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/GerMoren/junando.git",
|
|
20
|
+
"directory": "packages/create-junando-app"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^22.0.0",
|
|
28
|
+
"tsup": "^8.0.0",
|
|
29
|
+
"typescript": "^5.5.0",
|
|
30
|
+
"vitest": "^2.0.0"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"prebuild": "node scripts/sync-template.js",
|
|
34
|
+
"build": "tsup src/cli.ts --format esm --dts --tsconfig tsconfig.build.json",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"clean": "rm -rf dist template"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Express end-to-end example
|
|
2
|
+
|
|
3
|
+
> **This example is the template used by `create-junando-app`. Changes here ship to new users on next release.**
|
|
4
|
+
|
|
5
|
+
The canonical Junando demo. A broken Express endpoint triggers a Prometheus alert, Alertmanager forwards it to Junando, Junando asks an LLM for a structured diagnosis, and the result lands in Slack with the original `correlationId` intact.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
demo-app (Express)
|
|
9
|
+
└─ /api/checkout always returns 500 + logs an error with correlationId
|
|
10
|
+
└─ Prometheus scrapes http_errors_total
|
|
11
|
+
└─ Alert rule CheckoutEndpointFailing fires
|
|
12
|
+
└─ Alertmanager posts to junando-webhook
|
|
13
|
+
└─ Junando builds a cluster, asks the LLM, and notifies Slack
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Total time to first Slack message: about 5 minutes including filling in credentials.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
|
|
22
|
+
- Docker + Docker Compose
|
|
23
|
+
- A Slack bot token (or a Microsoft Teams Power Automate webhook — see `.env.example`)
|
|
24
|
+
- An LLM API key (Qwen, Claude, Gemini, or OpenRouter)
|
|
25
|
+
|
|
26
|
+
That is it. You do not need to clone the Junando monorepo or build any package — the example uses the published `ghcr.io/germoren/junando-webhook:latest` image by default.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Run it
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cd examples/express-end-to-end
|
|
34
|
+
|
|
35
|
+
cp .env.example .env
|
|
36
|
+
# edit .env and fill in LLM_API_KEY, SLACK_BOT_TOKEN, SLACK_SIGNING_SECRET, SLACK_CHANNEL
|
|
37
|
+
|
|
38
|
+
docker compose up -d
|
|
39
|
+
./scripts/simulate.sh
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Within ~30 seconds you should see a Slack message in the channel you configured. It will contain:
|
|
43
|
+
|
|
44
|
+
- The probable cause as inferred by the LLM
|
|
45
|
+
- Recommended next steps
|
|
46
|
+
- A link to the runbook declared in `prometheus/rules.yml`
|
|
47
|
+
- The `correlationId` from the first failing request, so you can pivot to logs
|
|
48
|
+
|
|
49
|
+
Tear down:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
docker compose down -v
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## What is happening behind the scenes
|
|
58
|
+
|
|
59
|
+
### `demo-app`
|
|
60
|
+
|
|
61
|
+
A 60-line Express app at `app/src/server.js`. The only thing worth pointing out is the **correlationId middleware**: every request gets a UUID (or reuses an incoming `x-correlation-id` header). That id is attached to every pino log line and surfaces in the 500 response body. Real apps should do the same so a single incident is greppable across logs, metrics, and incident summaries.
|
|
62
|
+
|
|
63
|
+
### Prometheus
|
|
64
|
+
|
|
65
|
+
Scrapes `demo-app:3001/metrics` every 5 seconds. The rule in `docker/prometheus/rules.yml` watches `http_errors_total{route="/api/checkout"}` and fires `CheckoutEndpointFailing` when the rate exceeds zero for 15 seconds.
|
|
66
|
+
|
|
67
|
+
### Alertmanager
|
|
68
|
+
|
|
69
|
+
Single route, single receiver: it forwards every alert to `http://junando-webhook:4000/webhook/alert`. The `send_resolved: true` flag means Junando also receives the resolution event when the alert clears.
|
|
70
|
+
|
|
71
|
+
### Junando webhook
|
|
72
|
+
|
|
73
|
+
The published `ghcr.io/germoren/junando-webhook` image. It deduplicates against Redis (TTL 5 min by default), clusters related alerts (120 s window), pulls representative log context from Loki when available, and sends the cluster to your configured LLM. The LLM response is mapped to a Slack Block Kit message and posted to `SLACK_CHANNEL`.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Inspect each step
|
|
78
|
+
|
|
79
|
+
| URL | What to look at |
|
|
80
|
+
|----------------------------------|-------------------------------------------------------|
|
|
81
|
+
| http://localhost:3001/health | Demo app health |
|
|
82
|
+
| http://localhost:3001/metrics | Raw Prometheus metrics including `http_errors_total` |
|
|
83
|
+
| http://localhost:9090/alerts | Prometheus alert state (PENDING → FIRING) |
|
|
84
|
+
| http://localhost:9093/#/alerts | Alertmanager queue and grouping |
|
|
85
|
+
| http://localhost:4000/health | Junando webhook health |
|
|
86
|
+
|
|
87
|
+
Logs:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
docker compose logs -f demo-app # see the failing requests + correlationIds
|
|
91
|
+
docker compose logs -f junando-webhook # see the cluster build, LLM call, Slack post
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Swap notifier to Microsoft Teams
|
|
97
|
+
|
|
98
|
+
In `.env`:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
NOTIFIER_TYPE=teams
|
|
102
|
+
TEAMS_WEBHOOK_URL=https://prod-XX.westus.logic.azure.com/workflows/.../invoke?api-version=2024-10-01&sp=...
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Comment out the three `SLACK_*` variables. Restart:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
docker compose up -d junando-webhook
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Junando posts an Adaptive Card to your Power Automate workflow. The rest of the pipeline is identical.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Contributor mode (build webhook from source)
|
|
116
|
+
|
|
117
|
+
If you are working on `@junando/core` or `@junando/webhook` and want this example to reflect your local changes:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
docker compose --profile dev up -d --build
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
This builds the webhook from `docker/Dockerfile.webhook` at the repo root instead of pulling the published image. Everything else is unchanged.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Troubleshooting
|
|
128
|
+
|
|
129
|
+
**No Slack message after 1 minute.**
|
|
130
|
+
Check the Junando logs (`docker compose logs junando-webhook`). The most common causes are an invalid `SLACK_BOT_TOKEN`, a channel the bot is not invited to, or the LLM provider returning an error (the log line will say so).
|
|
131
|
+
|
|
132
|
+
**Alertmanager says `dial tcp: lookup junando-webhook: no such host`.**
|
|
133
|
+
This means alertmanager and junando-webhook are not in the same Compose network. Make sure you ran `docker compose up` from this directory, not from the repo root.
|
|
134
|
+
|
|
135
|
+
**Prometheus alert never fires.**
|
|
136
|
+
Hit `/api/checkout` manually a few times (`curl http://localhost:3001/api/checkout`) and watch http://localhost:9090/alerts. If `http_errors_total` is incrementing but the alert stays GREEN, the scrape may not have caught up yet — wait 15 more seconds.
|
|
137
|
+
|
|
138
|
+
**The LLM call times out.**
|
|
139
|
+
Some free-tier providers throttle aggressively. Switch `LLM_PROVIDER` to `openrouter` and use a paid model, or set `LLM_FALLBACK_MODELS` to a comma-separated list of free models.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# --- LLM (required) ---
|
|
2
|
+
# Pick one provider and set the matching API key.
|
|
3
|
+
LLM_PROVIDER=qwen
|
|
4
|
+
LLM_API_KEY=replace-me
|
|
5
|
+
LLM_MODEL=
|
|
6
|
+
|
|
7
|
+
# --- Notifier (Slack) ---
|
|
8
|
+
NOTIFIER_TYPE=slack
|
|
9
|
+
SLACK_BOT_TOKEN=xoxb-replace-me
|
|
10
|
+
SLACK_SIGNING_SECRET=replace-me
|
|
11
|
+
SLACK_CHANNEL=#alerts
|
|
12
|
+
|
|
13
|
+
# To swap to Microsoft Teams, comment the three SLACK_* lines above and set:
|
|
14
|
+
# NOTIFIER_TYPE=teams
|
|
15
|
+
# TEAMS_WEBHOOK_URL=https://prod-XX.westus.logic.azure.com/workflows/.../invoke?api-version=2024-10-01&sp=...
|
|
16
|
+
|
|
17
|
+
# --- Infra (do not change for the example) ---
|
|
18
|
+
REDIS_URL=redis://redis:6379
|
|
19
|
+
LOKI_URL=http://loki:3100
|
|
20
|
+
SQS_QUEUE_URL=
|
|
21
|
+
APP_URL=http://localhost:4000
|
|
22
|
+
|
|
23
|
+
# --- Tunables ---
|
|
24
|
+
DEDUP_TTL_SECONDS=300
|
|
25
|
+
CLUSTER_WINDOW_MS=120000
|
|
26
|
+
|
|
27
|
+
# --- General ---
|
|
28
|
+
NODE_ENV=development
|
|
29
|
+
LOG_LEVEL=info
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
24
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "express-end-to-end-example",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Canonical end-to-end Junando example: Express app -> Prometheus -> Alertmanager -> Junando -> Slack",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "node --env-file=.env src/server.js",
|
|
9
|
+
"dev": "node --env-file=.env --watch src/server.js"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"express": "^4.21.0",
|
|
13
|
+
"pino": "^9.5.0",
|
|
14
|
+
"pino-http": "^10.3.0",
|
|
15
|
+
"prom-client": "^15.1.3"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import express from "express";
|
|
2
|
+
import client from "prom-client";
|
|
3
|
+
import pinoHttp from "pino-http";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
import pino from "pino";
|
|
6
|
+
|
|
7
|
+
const log = pino({ level: process.env.LOG_LEVEL ?? "info" });
|
|
8
|
+
const app = express();
|
|
9
|
+
|
|
10
|
+
// --- correlationId middleware ----------------------------------------------
|
|
11
|
+
// Propagates an incoming x-correlation-id header or generates one. Every log
|
|
12
|
+
// line, every metric label, and every error response carries this id so that
|
|
13
|
+
// a single incident is traceable end-to-end from app -> Prom -> Junando -> Slack.
|
|
14
|
+
app.use((req, res, next) => {
|
|
15
|
+
const id = req.header("x-correlation-id") ?? randomUUID();
|
|
16
|
+
req.correlationId = id;
|
|
17
|
+
res.setHeader("x-correlation-id", id);
|
|
18
|
+
next();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
app.use(
|
|
22
|
+
pinoHttp({
|
|
23
|
+
logger: log,
|
|
24
|
+
customProps: (req) => ({ correlationId: req.correlationId }),
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
// --- Prometheus metrics ----------------------------------------------------
|
|
29
|
+
const register = new client.Registry();
|
|
30
|
+
client.collectDefaultMetrics({ register });
|
|
31
|
+
|
|
32
|
+
const httpRequests = new client.Counter({
|
|
33
|
+
name: "http_requests_total",
|
|
34
|
+
help: "Total HTTP requests handled by the demo app",
|
|
35
|
+
labelNames: ["method", "route", "status"],
|
|
36
|
+
registers: [register],
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const httpErrors = new client.Counter({
|
|
40
|
+
name: "http_errors_total",
|
|
41
|
+
help: "Total HTTP 5xx responses from the demo app",
|
|
42
|
+
labelNames: ["route"],
|
|
43
|
+
registers: [register],
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// --- Routes ----------------------------------------------------------------
|
|
47
|
+
app.get("/health", (_req, res) => {
|
|
48
|
+
res.json({ status: "ok" });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
app.get("/api/orders/:id", (req, res) => {
|
|
52
|
+
httpRequests.inc({ method: "GET", route: "/api/orders/:id", status: 200 });
|
|
53
|
+
res.json({ id: req.params.id, status: "shipped" });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Intentionally broken endpoint. Every call returns 500 and increments
|
|
57
|
+
// http_errors_total. Prometheus alert rule (see prometheus/rules.yml) fires
|
|
58
|
+
// when the rate exceeds the threshold.
|
|
59
|
+
app.get("/api/checkout", (req, res) => {
|
|
60
|
+
req.log.error(
|
|
61
|
+
{ correlationId: req.correlationId, route: "/api/checkout" },
|
|
62
|
+
"checkout failed: payment provider unreachable",
|
|
63
|
+
);
|
|
64
|
+
httpRequests.inc({ method: "GET", route: "/api/checkout", status: 500 });
|
|
65
|
+
httpErrors.inc({ route: "/api/checkout" });
|
|
66
|
+
res.status(500).json({
|
|
67
|
+
error: "payment_provider_unreachable",
|
|
68
|
+
correlationId: req.correlationId,
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
app.get("/metrics", async (_req, res) => {
|
|
73
|
+
res.set("Content-Type", register.contentType);
|
|
74
|
+
res.end(await register.metrics());
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const port = Number(process.env.PORT ?? 3001);
|
|
78
|
+
app.listen(port, "0.0.0.0", () => {
|
|
79
|
+
log.info({ port }, "demo-app listening");
|
|
80
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
auth_enabled: false
|
|
2
|
+
|
|
3
|
+
server:
|
|
4
|
+
http_listen_port: 3100
|
|
5
|
+
|
|
6
|
+
common:
|
|
7
|
+
path_prefix: /loki
|
|
8
|
+
storage:
|
|
9
|
+
filesystem:
|
|
10
|
+
chunks_directory: /loki/chunks
|
|
11
|
+
rules_directory: /loki/rules
|
|
12
|
+
replication_factor: 1
|
|
13
|
+
ring:
|
|
14
|
+
kvstore:
|
|
15
|
+
store: inmemory
|
|
16
|
+
|
|
17
|
+
schema_config:
|
|
18
|
+
configs:
|
|
19
|
+
- from: 2024-01-01
|
|
20
|
+
store: tsdb
|
|
21
|
+
object_store: filesystem
|
|
22
|
+
schema: v13
|
|
23
|
+
index:
|
|
24
|
+
prefix: index_
|
|
25
|
+
period: 24h
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
global:
|
|
2
|
+
scrape_interval: 5s
|
|
3
|
+
evaluation_interval: 5s
|
|
4
|
+
|
|
5
|
+
rule_files:
|
|
6
|
+
- /etc/prometheus/rules.yml
|
|
7
|
+
|
|
8
|
+
alerting:
|
|
9
|
+
alertmanagers:
|
|
10
|
+
- static_configs:
|
|
11
|
+
- targets: ['alertmanager:9093']
|
|
12
|
+
|
|
13
|
+
scrape_configs:
|
|
14
|
+
- job_name: 'demo-app'
|
|
15
|
+
static_configs:
|
|
16
|
+
- targets: ['demo-app:3001']
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
groups:
|
|
2
|
+
- name: demo-app
|
|
3
|
+
interval: 10s
|
|
4
|
+
rules:
|
|
5
|
+
- alert: CheckoutEndpointFailing
|
|
6
|
+
expr: rate(http_errors_total{route="/api/checkout"}[30s]) > 0
|
|
7
|
+
for: 15s
|
|
8
|
+
labels:
|
|
9
|
+
severity: critical
|
|
10
|
+
service: demo-app
|
|
11
|
+
team: payments
|
|
12
|
+
annotations:
|
|
13
|
+
summary: 'Checkout endpoint returning 5xx errors'
|
|
14
|
+
description: |
|
|
15
|
+
The /api/checkout endpoint on demo-app is returning errors at a rate of
|
|
16
|
+
{{ $value }} req/s. Likely cause: payment provider unreachable.
|
|
17
|
+
runbook_url: 'https://example.com/runbooks/checkout'
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
name: junando-example
|
|
2
|
+
|
|
3
|
+
# Two modes:
|
|
4
|
+
# docker compose up -> use published junando-webhook image (default)
|
|
5
|
+
# docker compose --profile dev up -> build junando-webhook from the monorepo source
|
|
6
|
+
#
|
|
7
|
+
# The published mode is intended for users evaluating Junando.
|
|
8
|
+
# The dev mode is for contributors who change core/webhook code and want to see
|
|
9
|
+
# the effect end-to-end without publishing.
|
|
10
|
+
|
|
11
|
+
services:
|
|
12
|
+
demo-app:
|
|
13
|
+
build: ./app
|
|
14
|
+
ports: ['3001:3001']
|
|
15
|
+
environment:
|
|
16
|
+
- PORT=3001
|
|
17
|
+
- LOG_LEVEL=info
|
|
18
|
+
depends_on:
|
|
19
|
+
- prometheus
|
|
20
|
+
|
|
21
|
+
prometheus:
|
|
22
|
+
image: prom/prometheus:v2.53.0
|
|
23
|
+
ports: ['9090:9090']
|
|
24
|
+
volumes:
|
|
25
|
+
- ./docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
|
26
|
+
- ./docker/prometheus/rules.yml:/etc/prometheus/rules.yml:ro
|
|
27
|
+
|
|
28
|
+
alertmanager:
|
|
29
|
+
image: prom/alertmanager:v0.27.0
|
|
30
|
+
ports: ['9093:9093']
|
|
31
|
+
volumes:
|
|
32
|
+
- ./docker/alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml:ro
|
|
33
|
+
|
|
34
|
+
loki:
|
|
35
|
+
image: grafana/loki:3.0.0
|
|
36
|
+
ports: ['3100:3100']
|
|
37
|
+
volumes:
|
|
38
|
+
- ./docker/loki/loki-config.yml:/etc/loki/local-config.yaml:ro
|
|
39
|
+
command: -config.file=/etc/loki/local-config.yaml
|
|
40
|
+
|
|
41
|
+
redis:
|
|
42
|
+
image: redis:7-alpine
|
|
43
|
+
healthcheck:
|
|
44
|
+
test: ['CMD', 'redis-cli', 'ping']
|
|
45
|
+
interval: 5s
|
|
46
|
+
retries: 5
|
|
47
|
+
|
|
48
|
+
# Default: pull the published image. No build needed.
|
|
49
|
+
junando-webhook:
|
|
50
|
+
profiles: ['', 'default']
|
|
51
|
+
image: ghcr.io/germoren/junando-webhook:latest
|
|
52
|
+
ports: ['4000:4000']
|
|
53
|
+
env_file: .env
|
|
54
|
+
depends_on:
|
|
55
|
+
redis:
|
|
56
|
+
condition: service_healthy
|
|
57
|
+
restart: unless-stopped
|
|
58
|
+
|
|
59
|
+
# Dev profile: build from the monorepo Dockerfile. Same service name so
|
|
60
|
+
# alertmanager.yml does not need to change.
|
|
61
|
+
junando-webhook-dev:
|
|
62
|
+
profiles: ['dev']
|
|
63
|
+
build:
|
|
64
|
+
context: ../..
|
|
65
|
+
dockerfile: docker/Dockerfile.webhook
|
|
66
|
+
container_name: junando-webhook
|
|
67
|
+
ports: ['4000:4000']
|
|
68
|
+
env_file: .env
|
|
69
|
+
depends_on:
|
|
70
|
+
redis:
|
|
71
|
+
condition: service_healthy
|
|
72
|
+
restart: unless-stopped
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Triggers the broken /api/checkout endpoint enough times to fire the
|
|
3
|
+
# Prometheus alert rule. Each request gets a unique correlationId so you can
|
|
4
|
+
# follow it in pino logs, Prometheus metrics, and the Slack message.
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
HOST="${HOST:-http://localhost:3001}"
|
|
9
|
+
COUNT="${COUNT:-20}"
|
|
10
|
+
DELAY="${DELAY:-0.2}"
|
|
11
|
+
|
|
12
|
+
echo "Firing ${COUNT} failing checkout requests against ${HOST} ..."
|
|
13
|
+
|
|
14
|
+
for i in $(seq 1 "${COUNT}"); do
|
|
15
|
+
CID=$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)
|
|
16
|
+
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
17
|
+
-H "x-correlation-id: ${CID}" \
|
|
18
|
+
"${HOST}/api/checkout" || true)
|
|
19
|
+
printf " [%2d/%s] correlationId=%s -> %s\n" "${i}" "${COUNT}" "${CID}" "${STATUS}"
|
|
20
|
+
sleep "${DELAY}"
|
|
21
|
+
done
|
|
22
|
+
|
|
23
|
+
cat <<EOF
|
|
24
|
+
|
|
25
|
+
Done. What to watch next:
|
|
26
|
+
- Prometheus rules: http://localhost:9090/alerts
|
|
27
|
+
- Alertmanager queue: http://localhost:9093/#/alerts
|
|
28
|
+
- Junando logs: docker compose logs -f junando-webhook
|
|
29
|
+
- Slack channel: the one you configured in .env (SLACK_CHANNEL)
|
|
30
|
+
|
|
31
|
+
Expected timeline:
|
|
32
|
+
~15s alert CheckoutEndpointFailing transitions to FIRING in Prometheus
|
|
33
|
+
~20s Alertmanager posts to junando-webhook
|
|
34
|
+
~30s Junando publishes the LLM analysis to Slack
|
|
35
|
+
EOF
|