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

feat(indexer): Add grafana and alert service to local development #7257

Conversation

roninjin10
Copy link
Contributor

@roninjin10 roninjin10 commented Sep 15, 2023

  • add prometheus to docker-compose
  • add grafana to docker-compose
  • add new folder for holding grafana provisioning and configuration
  • Add alert service
  • Configure alert service
  • Configure gafana dashboard for api
  • Configure grafana dashboard for indexer
  • remove gateway/backend service
  • make docker-compose run against more networks than just goerli

@roninjin10
Copy link
Contributor Author

roninjin10 commented Sep 15, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@mergify mergify bot added the A-indexer Area: indexer label Sep 15, 2023
indexer:
condition: service_healthy

grafana:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service 'grafana' is running with a writable root filesystem. This may allow malicious applications to download and run additional payloads, or modify container files. If an application inside a container has to save something temporarily consider using a tmpfs. Add 'read_only: true' to this service to prevent this.

Ignore this finding from writable-filesystem-service.

depends_on:
postgres:
condition: service_healthy

ui:
prometheus:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service 'prometheus' is running with a writable root filesystem. This may allow malicious applications to download and run additional payloads, or modify container files. If an application inside a container has to save something temporarily consider using a tmpfs. Add 'read_only: true' to this service to prevent this.

Ignore this finding from writable-filesystem-service.

indexer:
condition: service_healthy

grafana:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service 'grafana' allows for privilege escalation via setuid or setgid binaries. Add 'no-new-privileges:true' in 'security_opt' to prevent this.

Ignore this finding from no-new-privileges.

depends_on:
postgres:
condition: service_healthy

ui:
prometheus:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service 'prometheus' allows for privilege escalation via setuid or setgid binaries. Add 'no-new-privileges:true' in 'security_opt' to prevent this.

Ignore this finding from no-new-privileges.

indexer:
condition: service_healthy

alertmanager:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service 'alertmanager' is running with a writable root filesystem. This may allow malicious applications to download and run additional payloads, or modify container files. If an application inside a container has to save something temporarily consider using a tmpfs. Add 'read_only: true' to this service to prevent this.

Ignore this finding from writable-filesystem-service.

indexer:
condition: service_healthy

alertmanager:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service 'alertmanager' allows for privilege escalation via setuid or setgid binaries. Add 'no-new-privileges:true' in 'security_opt' to prevent this.

Ignore this finding from no-new-privileges.

@roninjin10 roninjin10 changed the title feat(indexer): Add grafana to local development feat(indexer): Add grafana and alert service to local development Sep 15, 2023
@roninjin10 roninjin10 changed the base branch from develop to 09-01-feat_indexer_Add_sql_migrations_file September 15, 2023 03:31
@roninjin10 roninjin10 force-pushed the 09-14-feat_indexer_Add_grafana_to_local_development branch from 0791421 to 07e6b6e Compare September 15, 2023 03:31
@semgrep-app
Copy link
Contributor

semgrep-app bot commented Sep 15, 2023

Semgrep found 1 gorm-hardcoded-secret finding:

  • indexer/database/db.go: L51-55

A secret is hard-coded in the application. Secrets stored in source code, such as credentials, identifiers, and other types of sensitive data, can be leaked and used by internal or external malicious actors. Use environment variables to securely provide credentials and other secrets or retrieve them from a secure vault or Hardware Security Module (HSM).

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>indexer/database/db.go</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0("<b>[Line: 49]</b> #quot; password=%s#quot;")
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2("<b>[Line: 49]</b> dsn")
        end
        %% Sink

        subgraph Sink
            direction LR

            v1("<b>[Line: 51]</b> gorm.Open(postgres.Open(dsn), &gorm.Config{<br>			// The indexer will explicitly manage the transactions<br>			SkipDefaultTransaction: true,<br>			Logger:                 logger.Default.LogMode(logger.Silent),<br>		})")
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

    %% Clickable

    click v0 href "https://github.com/ethereum-optimism/optimism/blob/07e6b6e53a4988118488d265a5ee7f175a29d351/indexer/database/db.go#L49" "View in source" _blank
    click v1 href "https://github.com/ethereum-optimism/optimism/blob/07e6b6e53a4988118488d265a5ee7f175a29d351/indexer/database/db.go#L51" "View in source" _blank
    click v2 href "https://github.com/ethereum-optimism/optimism/blob/07e6b6e53a4988118488d265a5ee7f175a29d351/indexer/database/db.go#L49" "View in source" _blank
Loading
Ignore this finding from gorm-hardcoded-secret.

Semgrep found 1 gorm-empty-password finding:

  • indexer/database/db.go: L51-55

The application uses an empty credential. This can lead to unauthorized access by either an internal or external malicious actor. Use environment variables to securely provide credentials and other secrets or retrieve them from a secure vault or Hardware Security Module (HSM).

View Dataflow Graph
flowchart LR
    classDef invis fill:white, stroke: none
    classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none

    subgraph File0["<b>indexer/database/db.go</b>"]
        direction LR
        %% Source

        subgraph Source
            direction LR

            v0("<b>[Line: 49]</b> #quot; password=%s#quot;")
        end
        %% Intermediate

        subgraph Traces0[Traces]
            direction TB

            v2("<b>[Line: 49]</b> dsn")
        end
        %% Sink

        subgraph Sink
            direction LR

            v1("<b>[Line: 51]</b> gorm.Open(postgres.Open(dsn), &gorm.Config{<br>			// The indexer will explicitly manage the transactions<br>			SkipDefaultTransaction: true,<br>			Logger:                 logger.Default.LogMode(logger.Silent),<br>		})")
        end
    end
    %% Class Assignment
    Source:::invis
    Sink:::invis

    Traces0:::invis
    File0:::invis

    %% Connections

    Source --> Traces0
    Traces0 --> Sink

    %% Clickable

    click v0 href "https://github.com/ethereum-optimism/optimism/blob/07e6b6e53a4988118488d265a5ee7f175a29d351/indexer/database/db.go#L49" "View in source" _blank
    click v1 href "https://github.com/ethereum-optimism/optimism/blob/07e6b6e53a4988118488d265a5ee7f175a29d351/indexer/database/db.go#L51" "View in source" _blank
    click v2 href "https://github.com/ethereum-optimism/optimism/blob/07e6b6e53a4988118488d265a5ee7f175a29d351/indexer/database/db.go#L49" "View in source" _blank
Loading
Ignore this finding from gorm-empty-password.

@roninjin10 roninjin10 force-pushed the 09-14-feat_indexer_Add_grafana_to_local_development branch 2 times, most recently from 2cd7f9d to 7f3d0a1 Compare September 15, 2023 04:06
@roninjin10 roninjin10 changed the base branch from 09-01-feat_indexer_Add_sql_migrations_file to 09-15-fix_Add_migrations_to_dockerfile September 15, 2023 13:59
@roninjin10 roninjin10 force-pushed the 09-14-feat_indexer_Add_grafana_to_local_development branch from 7f3d0a1 to 4c5adcc Compare September 15, 2023 13:59
@roninjin10 roninjin10 force-pushed the 09-15-fix_Add_migrations_to_dockerfile branch from d7cfe44 to 0809213 Compare September 15, 2023 14:12
@roninjin10 roninjin10 force-pushed the 09-14-feat_indexer_Add_grafana_to_local_development branch from 4c5adcc to 2d80dd3 Compare September 15, 2023 14:12
Will Cory and others added 4 commits September 15, 2023 10:05
feat: Add alert manager

fix: Add chain preset id to docker compose

fix: Pass in database env variables in docker compose
@roninjin10 roninjin10 force-pushed the 09-15-fix_Add_migrations_to_dockerfile branch from 0809213 to f25a591 Compare September 15, 2023 17:07
@roninjin10 roninjin10 force-pushed the 09-14-feat_indexer_Add_grafana_to_local_development branch from 2d80dd3 to e961711 Compare September 15, 2023 17:07
@github-actions
Copy link
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale label Sep 30, 2023
@github-actions github-actions bot closed this Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-indexer Area: indexer Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant