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

fix logs #537

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix logs #537

wants to merge 1 commit into from

Conversation

klinch0
Copy link
Contributor

@klinch0 klinch0 commented Dec 20, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a HelmRelease configuration for monitoring agents in Kubernetes.
    • Added a new section for fluent-bit with configurations for readiness probes, volumes, and log processing.
  • Bug Fixes

    • Enhanced monitoring capabilities with detailed configurations for log management and external integrations.

@klinch0 klinch0 requested a review from kvaps as a code owner December 20, 2024 14:27
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Dec 20, 2024
Copy link
Contributor

coderabbitai bot commented Dec 20, 2024

Walkthrough

This pull request introduces a comprehensive HelmRelease configuration for monitoring agents in a Kubernetes environment. The configuration defines a structured approach to deploying monitoring tools like vmagent and fluent-bit, with detailed settings for log management, external labels, and integration with existing infrastructure. The changes enable conditional deployment based on addon settings and provide flexible, namespace-aware monitoring agent configurations.

Changes

File Change Summary
packages/apps/kubernetes/templates/helmreleases/monitoring-agents.yaml Added HelmRelease configuration for monitoring agents with conditional deployment, namespace handling, and detailed release specifications
packages/system/monitoring-agents/values.yaml Added new fluent-bit configuration section with readiness probes, daemon set volumes, volume mounts, output settings, and log filtering rules

Sequence Diagram

sequenceDiagram
    participant Cluster as Kubernetes Cluster
    participant HelmRelease as Monitoring Agents HelmRelease
    participant VmAgent as VmAgent
    participant FluentBit as Fluent-Bit

    Cluster->>HelmRelease: Check addon enabled
    alt Addon Enabled
        HelmRelease->>VmAgent: Deploy with external labels
        HelmRelease->>FluentBit: Deploy with log processing config
        FluentBit->>Cluster: Collect and forward logs
    end
Loading

Possibly related PRs

  • fix tenant labels #468: Modifies HelmRelease configuration for monitoring agents, specifically adjusting tenant label assignment and filter configurations

Suggested labels

size:XS, lgtm

Suggested reviewers

  • kvaps

Poem

🐰 Monitoring agents, hop and dance,
Logs and metrics in a Kubernetes trance,
Fluent-Bit filters, VmAgent's might,
Tracking clusters with precision so bright!
A rabbit's watch over digital streams 🔍


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/system/monitoring-agents/values.yaml (2)

309-313: Enhance readiness probe configuration

The current readiness probe configuration is minimal. Consider adding the following parameters for more robust health checking:

  • Use /api/v1/health instead of root path
  • Add appropriate timeouts and thresholds
 fluent-bit:
   readinessProbe:
     httpGet:
-      path: /
+      path: /api/v1/health
+    initialDelaySeconds: 10
+    periodSeconds: 30
+    timeoutSeconds: 5
+    failureThreshold: 3

313-325: Add SELinux configuration for volume mounts

The volume mounts look correct, but consider adding SELinux configuration to prevent permission issues on clusters with SELinux enabled.

   daemonSetVolumes:
     - name: varlog
       hostPath:
         path: /var/log
+        type: Directory
+      securityContext:
+        seLinuxOptions:
+          type: spc_t
     - name: varlibdockercontainers
       hostPath:
         path: /var/lib/docker/containers
+        type: Directory
+      securityContext:
+        seLinuxOptions:
+          type: spc_t
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c1ca19d and 20a58a9.

📒 Files selected for processing (2)
  • packages/apps/kubernetes/templates/helmreleases/monitoring-agents.yaml (0 hunks)
  • packages/system/monitoring-agents/values.yaml (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/apps/kubernetes/templates/helmreleases/monitoring-agents.yaml
🔇 Additional comments (1)
packages/system/monitoring-agents/values.yaml (1)

308-308: Verify service endpoints configuration

Please verify that the service endpoints are correctly configured and accessible:

  • vmagent writes to: vminsert-shortterm.tenant-root.svc:8480
  • fluent-bit writes to: vlogs-generic.tenant-root.svc:9428

Also applies to: 331-332

✅ Verification successful

Service endpoints are correctly templated and consistent

The service endpoints are correctly configured in both the values file and the Helm template:

  • The endpoints use consistent templating where tenant-root is the default value in values.yaml
  • The Helm template in monitoring-agents.yaml properly parameterizes the tenant using {{ $targetTenant }}
  • Port numbers (8480 and 9428) are consistent across configurations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of referenced services in the tenant-root namespace

# Check if the services exist in the tenant-root namespace
kubectl get svc vminsert-shortterm vlogs-generic -n tenant-root -o name

# Check if the ports are defined in the service specs
kubectl get svc vminsert-shortterm vlogs-generic -n tenant-root -o jsonpath='{range .items[*]}{.metadata.name}{" ports: "}{.spec.ports[*].port}{"\n"}{end}'

Length of output: 427


Script:

#!/bin/bash
# Let's verify the service endpoints configuration in the values.yaml file
rg -A 2 "vminsert-shortterm.tenant-root.svc:8480|vlogs-generic.tenant-root.svc:9428" packages/system/monitoring-agents/values.yaml

# Also search for any service endpoint configurations in the entire codebase
rg -A 2 "vminsert-shortterm|vlogs-generic" --type yaml

Length of output: 1402

Comment on lines +327 to +339
outputs: |
[OUTPUT]
Name http
Match kube.*
Host vlogs-generic.tenant-root.svc
port 9428
compress gzip
uri /insert/jsonline?_stream_fields=stream,kubernetes_pod_name,kubernetes_container_name,kubernetes_namespace_name&_msg_field=log&_time_field=date
format json_lines
json_date_format iso8601
header AccountID 0
header ProjectID 0
filters: |
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Enhance output configuration for reliability and security

The current output configuration lacks important reliability and security features:

  1. Missing retry mechanism for network failures
  2. No TLS configuration for secure communication
  3. Hard-coded AccountID/ProjectID values
     outputs: |
       [OUTPUT]
           Name http
           Match kube.*
           Host vlogs-generic.tenant-root.svc
           port 9428
           compress gzip
           uri /insert/jsonline?_stream_fields=stream,kubernetes_pod_name,kubernetes_container_name,kubernetes_namespace_name&_msg_field=log&_time_field=date
           format json_lines
           json_date_format iso8601
+          tls On
+          tls.verify On
+          retry_limit 5
+          net.keepalive On
+          net.keepalive_idle_timeout 30
           header AccountID 0
           header ProjectID 0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
outputs: |
[OUTPUT]
Name http
Match kube.*
Host vlogs-generic.tenant-root.svc
port 9428
compress gzip
uri /insert/jsonline?_stream_fields=stream,kubernetes_pod_name,kubernetes_container_name,kubernetes_namespace_name&_msg_field=log&_time_field=date
format json_lines
json_date_format iso8601
header AccountID 0
header ProjectID 0
filters: |
outputs: |
[OUTPUT]
Name http
Match kube.*
Host vlogs-generic.tenant-root.svc
port 9428
compress gzip
uri /insert/jsonline?_stream_fields=stream,kubernetes_pod_name,kubernetes_container_name,kubernetes_namespace_name&_msg_field=log&_time_field=date
format json_lines
json_date_format iso8601
tls On
tls.verify On
retry_limit 5
net.keepalive On
net.keepalive_idle_timeout 30
header AccountID 0
header ProjectID 0
filters: |

Comment on lines +339 to +361
filters: |
[FILTER]
Name kubernetes
Match kube.*
Merge_Log On
Keep_Log On
K8S-Logging.Parser On
K8S-Logging.Exclude On
[FILTER]
Name nest
Match *
Wildcard pod_name
Operation lift
Nested_under kubernetes
Add_prefix kubernetes_
[FILTER]
Name modify
Match *
Add tenant tenant-root
[FILTER]
Name modify
Match *
Add cluster root-cluster
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Parameterize tenant and cluster names in filters

The tenant and cluster names are currently hard-coded. These should be parameterized to support different environments and multi-tenant deployments.

     filters: |
       [FILTER]
           Name modify
           Match *
-          Add tenant tenant-root
+          Add tenant ${TENANT_NAME}
       [FILTER]
           Name modify
           Match *
-          Add cluster root-cluster
+          Add cluster ${CLUSTER_NAME}

Additionally, consider adding a filter to handle multiline logs (e.g., stack traces) before the Kubernetes filter:

     filters: |
+      [FILTER]
+          Name multiline
+          Match *
+          multiline.key_content log
+          multiline.parser java
       [FILTER]
           Name kubernetes

Committable suggestion skipped: line range outside the PR's diff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant