Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Masv add mertric #35

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions configfiles/datasource.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: 1

datasources:
- name: Prometheus
type: prometheus
url: http://prometheus:9090
isDefault: true
access: proxy
editable: true
File renamed without changes.
13 changes: 13 additions & 0 deletions configfiles/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
scrape_configs:
- job_name: apigw
scrape_interval: 10s
static_configs:
- targets:
- vc_apigw:8080

- job_name: persistent
scrape_interval: 10s
static_configs:
- targets:
- vc_persistent:8080

69 changes: 0 additions & 69 deletions dev_haproxy.cfg

This file was deleted.

45 changes: 38 additions & 7 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
image: docker.sunet.se/dc4eu/apigw:latest
restart: always
volumes:
- ./dev_config_docker.yaml:/config.yaml:ro
- ./configfiles/dev_config_docker.yaml:/config.yaml:ro
- /var/log/sunet:/var/log/sunet
depends_on:
- redis
Expand All @@ -24,7 +24,7 @@ services:
restart: always
volumes:
- ./cert:/cert:ro
- ./dev_config_docker.yaml:/config.yaml:ro
- ./configfiles/dev_config_docker.yaml:/config.yaml:ro
depends_on:
- redis
- mongo
Expand All @@ -39,7 +39,7 @@ services:
image: docker.sunet.se/dc4eu/registry:latest
restart: always
volumes:
- ./dev_config_docker.yaml:/config.yaml:ro
- ./configfiles/dev_config_docker.yaml:/config.yaml:ro
depends_on:
- redis
- mongo
Expand All @@ -54,7 +54,7 @@ services:
image: docker.sunet.se/dc4eu/cache:latest
restart: always
volumes:
- ./dev_config_docker.yaml:/config.yaml:ro
- ./configfiles/dev_config_docker.yaml:/config.yaml:ro
depends_on:
- redis
networks:
Expand All @@ -68,7 +68,7 @@ services:
image: docker.sunet.se/dc4eu/persistent:latest
restart: always
volumes:
- ./dev_config_docker.yaml:/config.yaml:ro
- ./configfiles/dev_config_docker.yaml:/config.yaml:ro
depends_on:
- redis
- mongo
Expand All @@ -83,7 +83,7 @@ services:
image: docker.sunet.se/dc4eu/py_pdfsigner_dev:latest
restart: always
volumes:
- ./dev_config_docker.yaml:/config.yaml:ro
- ./configfiles/dev_config_docker.yaml:/config.yaml:ro
- /var/log/sunet:/var/log/sunet
depends_on:
- redis
Expand All @@ -98,7 +98,7 @@ services:
image: docker.sunet.se/dc4eu/py_pdfvalidator_dev:latest
restart: always
volumes:
- ./dev_config_docker.yaml:/config.yaml:ro
- ./configfiles/dev_config_docker.yaml:/config.yaml:ro
- /var/log/sunet:/var/log/sunet
# - ./certs/SectigoRSADocumentSigningCA.crt:/app/SectigoRSADocumentSigningCA.crt:ro
# - ./certs/USERTrustRSAAddTrustCA.crt:/app/USERTrustRSAAddTrustCA.crt:ro
Expand Down Expand Up @@ -149,6 +149,36 @@ services:
environment:
- "COLLECTOR_OTLP_ENABLED=true"

prometheus:
image: prom/prometheus
container_name: prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
ports:
- 9090:9090
networks:
vc-net:
ipv4_address: 172.16.50.12
restart: unless-stopped
volumes:
- ./configfiles/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus

grafana:
image: grafana/grafana
container_name: grafana
ports:
- 3000:3000
networks:
vc-net:
ipv4_address: 172.16.50.13
restart: unless-stopped
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=grafana
volumes:
- ./configfiles/grafana:/etc/grafana/provisioning/datasources

networks:
vc-net:
driver: bridge
Expand All @@ -161,3 +191,4 @@ networks:
volumes:
redis_data:
mongo_data:
prometheus_data:
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/masv3971/gosdjwt v0.0.0-20240229085317-d406fd94329c
github.com/masv3971/gosunetca v0.0.4
github.com/moogar0880/problems v0.1.1
github.com/prometheus/client_golang v1.19.0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
github.com/stretchr/testify v1.9.0
github.com/swaggo/files v1.0.1
Expand All @@ -38,6 +39,7 @@ require (

require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
Expand All @@ -55,6 +57,9 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-sqlite3 v1.14.22 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
Expand Down
11 changes: 10 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/brianvoe/gofakeit/v6 v6.28.0 h1:Xib46XXuQfmlLS2EXRuJpqcw8St6qSZz75OUo0tgAW4=
github.com/brianvoe/gofakeit/v6 v6.28.0/go.mod h1:Xj58BMSnFqcn/fAQeSK+/PLtC5kSb7FJIq4JyGa8vEs=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
Expand Down Expand Up @@ -55,7 +57,6 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator v9.31.0+incompatible h1:UA72EPEogEnq76ehGdEDp4Mit+3FDh548oRqwVgNsHA=
github.com/go-playground/validator/v10 v10.19.0 h1:ol+5Fu+cSq9JD7SoSqe04GMI92cbn0+wvQ3bZ8b/AU4=
github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-redis/redismock/v9 v9.2.0 h1:ZrMYQeKPECZPjOj5u9eyOjg8Nnb0BS9lkVIZ6IpsKLw=
Expand Down Expand Up @@ -118,6 +119,14 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU=
github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k=
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
github.com/prometheus/common v0.48.0 h1:QO8U2CdOzSn1BBsmXJXduaaW+dY/5QLjfB8svtSzKKE=
github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc=
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/redis/go-redis/v9 v9.5.1 h1:H1X4D3yHPaYrkL5X06Wh6xNVM/pX0Ft4RV0vMGvLBh8=
github.com/redis/go-redis/v9 v9.5.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
Expand Down
18 changes: 9 additions & 9 deletions internal/apigw/apiv1/handlers_eduseal.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type PDFSignReply struct {
// @Success 200 {object} PDFSignReply "Success"
// @Failure 400 {object} helpers.ErrorResponse "Bad Request"
// @Param req body PDFSignRequest true " "
// @Router /ladok/pdf/sign [post]
// @Router /leduseal/pdf/sign [post]
func (c *Client) PDFSign(ctx context.Context, req *PDFSignRequest) (*PDFSignReply, error) {
ctx, span := c.tp.Start(ctx, "apiv1:PDFSign")
defer span.End()
Expand All @@ -55,7 +55,7 @@ func (c *Client) PDFSign(ctx context.Context, req *PDFSignRequest) (*PDFSignRepl
Base64Data: req.PDF,
}

_, err := c.simpleQueue.LadokSign.Enqueue(ctx, unsignedDocument)
_, err := c.simpleQueue.EduSealSign.Enqueue(ctx, unsignedDocument)
if err != nil {
span.SetStatus(codes.Error, err.Error())
return nil, err
Expand All @@ -64,7 +64,7 @@ func (c *Client) PDFSign(ctx context.Context, req *PDFSignRequest) (*PDFSignRepl
persistentDocument := &types.Document{
TransactionID: transactionID,
}
_, err = c.simpleQueue.LadokPersistentSave.Enqueue(ctx, persistentDocument)
_, err = c.simpleQueue.EduSealPersistentSave.Enqueue(ctx, persistentDocument)
if err != nil {
span.SetStatus(codes.Error, err.Error())
return nil, err
Expand Down Expand Up @@ -102,7 +102,7 @@ type PDFValidateReply struct {
// @Success 200 {object} PDFValidateReply "Success"
// @Failure 400 {object} helpers.ErrorResponse "Bad Request"
// @Param req body PDFValidateRequest true " "
// @Router /ladok/pdf/validate [post]
// @Router /eduseal/pdf/validate [post]
func (c *Client) PDFValidate(ctx context.Context, req *PDFValidateRequest) (*PDFValidateReply, error) {
ctx, span := c.tp.Start(ctx, "apiv1:PDFValidate")
defer span.End()
Expand All @@ -111,7 +111,7 @@ func (c *Client) PDFValidate(ctx context.Context, req *PDFValidateRequest) (*PDF
Base64Data: req.PDF,
}

job, err := c.simpleQueue.LadokValidate.Enqueue(ctx, validateCandidate)
job, err := c.simpleQueue.EduSealValidate.Enqueue(ctx, validateCandidate)
if err != nil {
span.SetStatus(codes.Error, err.Error())
return nil, err
Expand Down Expand Up @@ -150,7 +150,7 @@ func (c *Client) PDFValidate(ctx context.Context, req *PDFValidateRequest) (*PDF
return nil, err
}
if validationReply.Error != "" {
span.SetStatus(codes.Error, err.Error())
span.SetStatus(codes.Error, validationReply.Error)
return nil, helpers.NewErrorFromError(errors.New(validationReply.Error))
}

Expand Down Expand Up @@ -192,7 +192,7 @@ type PDFGetSignedReply struct {
// @Success 200 {object} PDFGetSignedReply "Success"
// @Failure 400 {object} helpers.ErrorResponse "Bad Request"
// @Param transaction_id path string true "transaction_id"
// @Router /ladok/pdf/{transaction_id} [get]
// @Router /eduseal/pdf/{transaction_id} [get]
func (c *Client) PDFGetSigned(ctx context.Context, req *PDFGetSignedRequest) (*PDFGetSignedReply, error) {
ctx, span := c.tp.Start(ctx, "apiv1:PDFGetSigned")
defer span.End()
Expand Down Expand Up @@ -223,7 +223,7 @@ func (c *Client) PDFGetSigned(ctx context.Context, req *PDFGetSignedRequest) (*P
TransactionID: req.TransactionID,
}

if _, err := c.simpleQueue.LadokDelSigned.Enqueue(ctx, delReq); err != nil {
if _, err := c.simpleQueue.EduSealDelSigned.Enqueue(ctx, delReq); err != nil {
c.log.Info("PDFGetSigned", "Enqueue", err)
span.SetStatus(codes.Error, err.Error())
return nil, err
Expand Down Expand Up @@ -274,7 +274,7 @@ type PDFRevokeReply struct {
// @Success 200 {object} PDFRevokeReply "Success"
// @Failure 400 {object} helpers.ErrorResponse "Bad Request"
// @Param transaction_id path string true "transaction_id"
// @Router /ladok/pdf/revoke/{transaction_id} [put]
// @Router /eduseal/pdf/revoke/{transaction_id} [put]
func (c *Client) PDFRevoke(ctx context.Context, req *PDFRevokeRequest) (*PDFRevokeReply, error) {
ctx, span := c.tp.Start(ctx, "apiv1:PDFRevoke")
defer span.End()
Expand Down
14 changes: 7 additions & 7 deletions internal/apigw/apiv1/handlers_vc.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type IDMappingReply struct {
// @Success 200 {object} IDMappingReply "Success"
// @Failure 400 {object} helpers.ErrorResponse "Bad Request"
// @Param req body model.MetaData true " "
// @Router /id_mapping [post]
// @Router /id/mapping [post]
func (c *Client) IDMapping(ctx context.Context, reg *IDMappingRequest) (*IDMappingReply, error) {
if err := helpers.Check(ctx, c.cfg, reg, c.log); err != nil {
return nil, err
Expand Down Expand Up @@ -221,16 +221,16 @@ type GetDocumentAttestationReply struct {

// GetDocumentAttestation return a specific document ??
//
// @Summary GetDocumentByCollectCode
// @ID get-document-collect-code
// @Description Get document by collect code endpoint
// @Summary GetDocumentAttestation
// @ID get-document-attestation
// @Description Get document attestation endpoint
// @Tags dc4eu
// @Accept json
// @Produce json
// @Success 200 {object} GetDocumentReply "Success"
// @Success 200 {object} GetDocumentAttestationReply "Success"
// @Failure 400 {object} helpers.ErrorResponse "Bad Request"
// @Param req body model.MetaData true " "
// @Router /document/collection_code [post]
// @Param req body GetDocumentAttestationRequest true " "
// @Router /document/attestation [post]
func (c *Client) GetDocumentAttestation(ctx context.Context, req *GetDocumentAttestationRequest) (*GetDocumentAttestationReply, error) {
if err := helpers.Check(ctx, c.cfg, req, c.log); err != nil {
return nil, err
Expand Down
Loading
Loading