grafana/foundation-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

grafana/foundation-sdk

Composer 安装命令:

composer require grafana/foundation-sdk

包简介

A set of tools, types and libraries for building and manipulating Grafana objects.

README 文档

README

The Grafana Foundation SDK is a set of types, and builder libraries that let you define Grafana dashboards and other resources using strongly typed code. By writing your resources as code, you can:

  • Leverage strong typing: Catch errors at compile time, ensuring more reliable configurations.
  • Enhance version control: Track changes seamlessly using standard version control systems like Git.
  • Automate deployments: Integrate dashboard provisioning into your CI/CD pipelines for consistent and repeatable setups.

The SDK supports multiple programming languages, including Go, TypeScript, Python, PHP, and Java, so you can choose the one that best fits your development environment.

Note

This SDK is best suited for Grafana >= 12, but will work with Grafana >= 10.

Overview

Here's a quick overview of how the SDK works:

  • Builder pattern: The SDK implements the builder pattern to let you define dashboards fluently. You start with a DashboardBuilder, then add panels, queries, and other components step by step.
  • Strong typing: Everything in the SDK is strongly typed. This gives you autocompletion in your IDE, catches mistakes early, and helps ensure you're always using valid configuration values.
  • Structured options: When a configuration gets complex (like data reduction or display settings), the SDK uses typed option builders to keep things readable and predictable.
  • Resources: Multiple resources are supported by the SDK. Dashboards, alerts, …

For example, here is how a dashboard can be built in Go:

package main

import (
    "encoding/json"
    "fmt"

    "github.com/grafana/grafana-foundation-sdk/go/common"
    "github.com/grafana/grafana-foundation-sdk/go/dashboard"
    "github.com/grafana/grafana-foundation-sdk/go/prometheus"
    "github.com/grafana/grafana-foundation-sdk/go/timeseries"
    "github.com/grafana/grafana-foundation-sdk/go/units"
)

func main() {
    builder := dashboard.NewDashboardBuilder("Sample dashboard").
        Uid("generated-from-go").
        Tags([]string{"generated", "from", "go"}).
        Refresh("1m").
        Time("now-30m", "now").
        Timezone(common.TimeZoneBrowser).
        WithRow(dashboard.NewRowBuilder("Overview")).
        WithPanel(
            timeseries.NewPanelBuilder().
                Title("Network Received").
                Unit(units.BitsPerSecondSI).
                Min(0).
                WithTarget(
                    prometheus.NewDataqueryBuilder().
                        Expr(`rate(node_network_receive_bytes_total{job="integrations/raspberrypi-node", device!="lo"}[$__rate_interval]) * 8`).
                        LegendFormat("{{ device }}"),
                ),
        )

    sampleDashboard, err := builder.Build()
    if err != nil {
        panic(err)
    }
    dashboardJson, err := json.MarshalIndent(sampleDashboard, "", "  ")
    if err != nil {
        panic(err)
    }

    fmt.Println(string(dashboardJson))
}

Note

More examples can be found in the ./examples/ folder.

Publishing resources

After you've defined your resource as code, call the build() function (its actual name might be slightly different depending on language choice) and output the result as a JSON.

With the JSON payload, you can:

Next steps

With the basics of using the Grafana Foundation SDK in mind, here are some possible next steps:

Contributing

Contributions are welcome! See CONTRIBUTING.md for more information.

Maturity

The code in this repository should be considered as "public preview". While it is used by Grafana Labs in production, it still is under active development.

Note

Bugs and issues are handled solely by Engineering teams. On-call support or SLAs are not available.

License

Apache 2.0 License

grafana/foundation-sdk 适用场景与选型建议

grafana/foundation-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 44.36k 次下载、GitHub Stars 达 239, 最近一次更新时间为 2024 年 06 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「Metrics」 「sdk」 「logs」 「traces」 「grafana」 「observability」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 grafana/foundation-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 grafana/foundation-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 grafana/foundation-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 44.36k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 239
  • 点击次数: 30
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 239
  • Watchers: 105
  • Forks: 17
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2024-06-25