-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial version of webexporter (#1)
Initial release version of the web exporter.
- Loading branch information
Showing
103 changed files
with
12,572 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
**/node_modules | ||
artifacts/ | ||
tools/ | ||
**/bin | ||
**/obj | ||
**/wwwroot | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
*.db | ||
|
||
*.user | ||
|
||
**/bin/ | ||
**/obj/ | ||
**/node_modules/ | ||
**/wwwroot/ | ||
|
||
tools/ | ||
artifacts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
include: | ||
- "https://gitlab.com/smartive/open-source/gitlab-ci-templates/raw/master/templates.yml" | ||
|
||
stages: | ||
- test | ||
- release | ||
|
||
.public-docker: | ||
extends: .base | ||
image: docker:latest | ||
variables: | ||
DOCKER_DRIVER: overlay2 | ||
DOCKER_HOST: tcp://localhost:2375 | ||
DOCKER_FILE: ./Dockerfile | ||
DOCKER_TAG: "" | ||
DOCKER_CONTEXT: "." | ||
DOCKER_BUILDKIT: "1" | ||
services: | ||
- docker:dind | ||
before_script: | ||
- docker login -u $DOCKER_REGISTRY_USER -p $DOCKER_REGISTRY_PASSWORD | ||
script: | ||
- docker build --file $DOCKER_FILE -t $DOCKER_TAG $DOCKER_CONTEXT | ||
after_script: | ||
- docker push $DOCKER_TAG | ||
|
||
test: | ||
extends: .public-docker | ||
stage: test | ||
before_script: [] | ||
after_script: [] | ||
script: | ||
- docker build --file $DOCKER_FILE --target build $DOCKER_CONTEXT | ||
except: | ||
- master | ||
- tags | ||
|
||
release: | ||
extends: .create-release | ||
stage: release | ||
only: | ||
- master | ||
|
||
deploy: | ||
extends: .public-docker | ||
stage: release | ||
variables: | ||
DOCKER_TAG: "smartive/web-exporter:$CI_COMMIT_TAG" | ||
only: | ||
- tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"repositoryUrl": "https://github.com/smartive/web-exporter.git", | ||
"verifyConditions": "@semantic-release/github", | ||
"prepare": false, | ||
"publish": "@semantic-release/github" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
### Build node related things | ||
FROM node:10 as nodejs | ||
|
||
WORKDIR /app | ||
|
||
COPY ./src/Frontend ./frontend | ||
COPY ./src/WebApp ./webapp | ||
|
||
RUN cd frontend && npm ci && npm run build | ||
RUN cd webapp && npm ci | ||
|
||
### Build Backend | ||
FROM microsoft/dotnet:2.2-sdk AS build | ||
|
||
WORKDIR /app | ||
|
||
COPY . ./ | ||
COPY --from=nodejs /app/frontend/build ./src/WebApp/wwwroot | ||
|
||
RUN ./build.sh | ||
|
||
### Deploy | ||
FROM microsoft/dotnet:2.2-runtime as final | ||
|
||
WORKDIR /app | ||
EXPOSE 80 | ||
|
||
RUN apt-get update && apt-get install -y gnupg2 && \ | ||
curl -sL https://deb.nodesource.com/setup_10.x | bash - && \ | ||
apt-get install -y nodejs && \ | ||
ln -sf /usr/share/zoneinfo/Europe/Zurich /etc/localtime && \ | ||
dpkg-reconfigure -f noninteractive tzdata && \ | ||
mkdir -p /app/Data | ||
|
||
COPY --from=build /app/artifacts . | ||
COPY --from=nodejs /app/webapp/node_modules ./node_modules | ||
|
||
CMD dotnet WebApp.dll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Web Exporter for prometheus | ||
|
||
// badges. | ||
|
||
This is a "smart" exporter for prometheus. This exporter should extend / replace the | ||
basic exporter of prometheus with the goal to perform more specific tests on api | ||
calls. While you can scrap for web targets with the basic exporter, it is (merely) only | ||
possible to check for a successful status code. | ||
|
||
This exporter however comes with a small management UI that allows you to define the | ||
tests by themself with url, http method and of course a name. | ||
|
||
After this step, you may define additional labels that are exported to prometheus during | ||
scrapping. You may also add request headers - like authorization headers, api version | ||
headers, language headers and so forth. | ||
|
||
Last but not least, you can define "response-tests" that can be written in javascript | ||
in [`monaco`](https://microsoft.github.io/monaco-editor/) (which is the editor that powers vscode) | ||
with `lodash` and `jsonpath` and a custom logger at your disposal. When some tests are defined, | ||
the web-check will execute them with the request and the response one by one and the test will | ||
only result in a `true` result when all of them are truthly executed. | ||
|
||
The javascript code is run by a node `vm2` instance that has a very strict timeout of one | ||
second to prevent malicious code like `while (true) {}` from running to infinity and beyond. | ||
|
||
The metrics are exposed on the `/metrics` endpoint and can be crapped by prometheus at any time. | ||
|
||
// describe deployment? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{2E5B837F-D508-41F7-87E1-C3EE5CE486E8}" | ||
ProjectSection(SolutionItems) = preProject | ||
build.cake = build.cake | ||
build.sh = build.sh | ||
.gitlab-ci.yml = .gitlab-ci.yml | ||
Dockerfile = Dockerfile | ||
EndProjectSection | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApp", "src\WebApp\WebApp.csproj", "{E431D29E-8095-48A0-90A9-A3E04E00A326}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DAL", "src\DAL\DAL.csproj", "{85495373-8DBB-45B8-B76F-F28E2ED37190}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataAccess", "src\DataAccess\DataAccess.csproj", "{5AFB83C1-EFF1-498C-9E93-9E7C7FCCB930}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "configs", "configs", "{30F400A6-5F07-42C6-B679-14D41A58FBD1}" | ||
ProjectSection(SolutionItems) = preProject | ||
project.ruleset = project.ruleset | ||
stylecop.json = stylecop.json | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{E431D29E-8095-48A0-90A9-A3E04E00A326}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E431D29E-8095-48A0-90A9-A3E04E00A326}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E431D29E-8095-48A0-90A9-A3E04E00A326}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E431D29E-8095-48A0-90A9-A3E04E00A326}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{85495373-8DBB-45B8-B76F-F28E2ED37190}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{85495373-8DBB-45B8-B76F-F28E2ED37190}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{85495373-8DBB-45B8-B76F-F28E2ED37190}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{85495373-8DBB-45B8-B76F-F28E2ED37190}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{5AFB83C1-EFF1-498C-9E93-9E7C7FCCB930}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5AFB83C1-EFF1-498C-9E93-9E7C7FCCB930}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5AFB83C1-EFF1-498C-9E93-9E7C7FCCB930}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5AFB83C1-EFF1-498C-9E93-9E7C7FCCB930}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/////////////////////////////////////////////////////////////////////////////// | ||
// ARGUMENTS | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
var target = Argument("target", "Default"); | ||
var configuration = Argument("configuration", "Release"); | ||
var artifactsDirectory = MakeAbsolute(Directory("./artifacts")); | ||
var solution = "./WebExporter.sln"; | ||
|
||
/////////////////////////////////////////////////////////////////////////////// | ||
// TASKS | ||
/////////////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Clean") | ||
.Does(() => | ||
{ | ||
Information("Clean up artifacts directory"); | ||
CleanDirectory(artifactsDirectory); | ||
Information("Clean any previous build"); | ||
DotNetCoreClean(solution, new DotNetCoreCleanSettings | ||
{ | ||
Configuration = configuration | ||
}); | ||
}); | ||
|
||
Task("Build") | ||
.Does(() => | ||
{ | ||
Information("Build and publish WebExporter"); | ||
DotNetCorePublish(solution, new DotNetCorePublishSettings | ||
{ | ||
Configuration = configuration, | ||
OutputDirectory = artifactsDirectory, | ||
Runtime = "linux-x64", | ||
}); | ||
}); | ||
|
||
Task("Default") | ||
.IsDependentOn("Clean") | ||
.IsDependentOn("Build"); | ||
|
||
RunTarget(target); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
|
||
########################################################################## | ||
# This is the Cake bootstrapper script for Linux and OS X. | ||
# This file was downloaded from https://github.com/cake-build/resources | ||
# Feel free to change this file to fit your needs. | ||
########################################################################## | ||
|
||
# Define directories. | ||
CAKE_VERSION=0.32.1 | ||
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
TOOLS_DIR=$SCRIPT_DIR/tools | ||
TOOLS_PROJ=$TOOLS_DIR/tools.csproj | ||
CAKE_DLL=$TOOLS_DIR/Cake.CoreCLR.$CAKE_VERSION/cake.coreclr/$CAKE_VERSION/Cake.dll | ||
|
||
# Make sure the tools folder exist. | ||
if [ ! -d "$TOOLS_DIR" ]; then | ||
mkdir -p "$TOOLS_DIR" | ||
fi | ||
|
||
# Define default arguments. | ||
SCRIPT="build.cake" | ||
CAKE_ARGUMENTS=() | ||
|
||
# Parse arguments. | ||
for i in "$@"; do | ||
case $1 in | ||
-s|--script) SCRIPT="$2"; shift ;; | ||
--) shift; CAKE_ARGUMENTS+=("$@"); break ;; | ||
*) CAKE_ARGUMENTS+=("$1") ;; | ||
esac | ||
shift | ||
done | ||
|
||
# Make sure the tools folder exist. | ||
if [ ! -d "$TOOLS_DIR" ]; then | ||
mkdir "$TOOLS_DIR" | ||
fi | ||
|
||
########################################################################### | ||
# INSTALL CAKE | ||
########################################################################### | ||
|
||
if [ ! -f "$CAKE_DLL" ]; then | ||
echo "<Project Sdk=\"Microsoft.NET.Sdk\"><PropertyGroup><OutputType>Exe</OutputType><TargetFramework>netcoreapp2.2</TargetFramework></PropertyGroup></Project>" > $TOOLS_PROJ | ||
dotnet add $TOOLS_PROJ package cake.coreclr -v $CAKE_VERSION --package-directory $TOOLS_DIR/Cake.CoreCLR.$CAKE_VERSION | ||
fi | ||
|
||
# Make sure that Cake has been installed. | ||
if [ ! -f "$CAKE_DLL" ]; then | ||
echo "Could not find Cake.exe at '$CAKE_DLL'." | ||
exit 1 | ||
fi | ||
|
||
########################################################################### | ||
# RUN BUILD SCRIPT | ||
########################################################################### | ||
|
||
# Start Cake | ||
exec dotnet "$CAKE_DLL" $SCRIPT "${CAKE_ARGUMENTS[@]}" |
Oops, something went wrong.