1. Packages
  2. Grafana Cloud
  3. API Docs
  4. oss
  5. getLibraryPanel
Grafana v2.18.0 published on Wednesday, Dec 3, 2025 by pulumiverse
grafana logo
Grafana v2.18.0 published on Wednesday, Dec 3, 2025 by pulumiverse

    Data source for retrieving a single library panel by name or uid.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as grafana from "@pulumiverse/grafana";
    import * as std from "@pulumi/std";
    
    // create a minimal library panel inside the General folder
    const test = new grafana.oss.LibraryPanel("test", {
        name: "test name",
        modelJson: JSON.stringify({
            title: "test name",
            type: "text",
            version: 0,
        }),
    });
    const fromName = grafana.oss.getLibraryPanelOutput({
        name: test.name,
    });
    const fromUid = grafana.oss.getLibraryPanelOutput({
        uid: test.uid,
    });
    // create library panels to be added to a dashboard
    const dashboard = new grafana.oss.LibraryPanel("dashboard", {
        name: "panel",
        modelJson: JSON.stringify({
            gridPos: {
                x: 0,
                y: 0,
                h: 10,
                w: 10,
            },
            title: "panel",
            type: "text",
            version: 0,
        }),
    });
    // create a dashboard using the library panel
    // `merge()` will add `libraryPanel` attribute to each library panel JSON
    // Grafana will then connect any library panels found in dashboard JSON
    const withLibraryPanel = new grafana.oss.Dashboard("with_library_panel", {configJson: JSON.stringify({
        id: 12345,
        panels: [std.index.merge({
            input: [
                std.index.jsondecode({
                    input: dashboard.modelJson,
                }).result,
                {
                    libraryPanel: {
                        name: dashboard.name,
                        uid: dashboard.uid,
                    },
                },
            ],
        }).result],
        title: "Production Overview",
        tags: ["templated"],
        timezone: "browser",
        schemaVersion: 16,
        version: 0,
        refresh: "25s",
    })});
    // dashboard_ids list attribute should contain dashboard id 12345
    const connectedToDashboard = grafana.oss.getLibraryPanelOutput({
        uid: dashboard.uid,
    });
    
    import pulumi
    import json
    import pulumi_grafana as grafana
    import pulumi_std as std
    import pulumiverse_grafana as grafana
    
    # create a minimal library panel inside the General folder
    test = grafana.oss.LibraryPanel("test",
        name="test name",
        model_json=json.dumps({
            "title": "test name",
            "type": "text",
            "version": 0,
        }))
    from_name = grafana.oss.get_library_panel_output(name=test.name)
    from_uid = grafana.oss.get_library_panel_output(uid=test.uid)
    # create library panels to be added to a dashboard
    dashboard = grafana.oss.LibraryPanel("dashboard",
        name="panel",
        model_json=json.dumps({
            "gridPos": {
                "x": 0,
                "y": 0,
                "h": 10,
                "w": 10,
            },
            "title": "panel",
            "type": "text",
            "version": 0,
        }))
    # create a dashboard using the library panel
    # `merge()` will add `libraryPanel` attribute to each library panel JSON
    # Grafana will then connect any library panels found in dashboard JSON
    with_library_panel = grafana.oss.Dashboard("with_library_panel", config_json=json.dumps({
        "id": 12345,
        "panels": [std.index.merge(input=[
            std.index.jsondecode(input=dashboard.model_json)["result"],
            {
                "libraryPanel": {
                    "name": dashboard.name,
                    "uid": dashboard.uid,
                },
            },
        ])["result"]],
        "title": "Production Overview",
        "tags": ["templated"],
        "timezone": "browser",
        "schemaVersion": 16,
        "version": 0,
        "refresh": "25s",
    }))
    # dashboard_ids list attribute should contain dashboard id 12345
    connected_to_dashboard = grafana.oss.get_library_panel_output(uid=dashboard.uid)
    
    package main
    
    import (
    	"encoding/json"
    
    	"github.com/pulumi/pulumi-std/sdk/go/std"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumiverse/pulumi-grafana/sdk/v2/go/grafana/oss"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		tmpJSON0, err := json.Marshal(map[string]interface{}{
    			"title":   "test name",
    			"type":    "text",
    			"version": 0,
    		})
    		if err != nil {
    			return err
    		}
    		json0 := string(tmpJSON0)
    		// create a minimal library panel inside the General folder
    		test, err := oss.NewLibraryPanel(ctx, "test", &oss.LibraryPanelArgs{
    			Name:      pulumi.String("test name"),
    			ModelJson: pulumi.String(json0),
    		})
    		if err != nil {
    			return err
    		}
    		_ = oss.LookupLibraryPanelOutput(ctx, oss.GetLibraryPanelOutputArgs{
    			Name: test.Name,
    		}, nil)
    		_ = oss.LookupLibraryPanelOutput(ctx, oss.GetLibraryPanelOutputArgs{
    			Uid: test.Uid,
    		}, nil)
    		tmpJSON1, err := json.Marshal(map[string]interface{}{
    			"gridPos": map[string]interface{}{
    				"x": 0,
    				"y": 0,
    				"h": 10,
    				"w": 10,
    			},
    			"title":   "panel",
    			"type":    "text",
    			"version": 0,
    		})
    		if err != nil {
    			return err
    		}
    		json1 := string(tmpJSON1)
    		// create library panels to be added to a dashboard
    		dashboard, err := oss.NewLibraryPanel(ctx, "dashboard", &oss.LibraryPanelArgs{
    			Name:      pulumi.String("panel"),
    			ModelJson: pulumi.String(json1),
    		})
    		if err != nil {
    			return err
    		}
    		tmpJSON2, err := json.Marshal(map[string]interface{}{
    			"id": 12345,
    			"panels": []interface{}{
    				std.Merge(ctx, map[string]interface{}{
    					"input": []interface{}{
    						std.Jsondecode(ctx, map[string]interface{}{
    							"input": dashboard.ModelJson,
    						}, nil).Result,
    						map[string]interface{}{
    							"libraryPanel": map[string]interface{}{
    								"name": dashboard.Name,
    								"uid":  dashboard.Uid,
    							},
    						},
    					},
    				}, nil).Result,
    			},
    			"title": "Production Overview",
    			"tags": []string{
    				"templated",
    			},
    			"timezone":      "browser",
    			"schemaVersion": 16,
    			"version":       0,
    			"refresh":       "25s",
    		})
    		if err != nil {
    			return err
    		}
    		json2 := string(tmpJSON2)
    		// create a dashboard using the library panel
    		// `merge()` will add `libraryPanel` attribute to each library panel JSON
    		// Grafana will then connect any library panels found in dashboard JSON
    		_, err = oss.NewDashboard(ctx, "with_library_panel", &oss.DashboardArgs{
    			ConfigJson: pulumi.String(json2),
    		})
    		if err != nil {
    			return err
    		}
    		// dashboard_ids list attribute should contain dashboard id 12345
    		_ = oss.LookupLibraryPanelOutput(ctx, oss.GetLibraryPanelOutputArgs{
    			Uid: dashboard.Uid,
    		}, nil)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text.Json;
    using Pulumi;
    using Grafana = Pulumi.Grafana;
    using Grafana = Pulumiverse.Grafana;
    using Std = Pulumi.Std;
    
    return await Deployment.RunAsync(() => 
    {
        // create a minimal library panel inside the General folder
        var test = new Grafana.Oss.LibraryPanel("test", new()
        {
            Name = "test name",
            ModelJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["title"] = "test name",
                ["type"] = "text",
                ["version"] = 0,
            }),
        });
    
        var fromName = Grafana.Oss.GetLibraryPanel.Invoke(new()
        {
            Name = test.Name,
        });
    
        var fromUid = Grafana.Oss.GetLibraryPanel.Invoke(new()
        {
            Uid = test.Uid,
        });
    
        // create library panels to be added to a dashboard
        var dashboard = new Grafana.Oss.LibraryPanel("dashboard", new()
        {
            Name = "panel",
            ModelJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["gridPos"] = new Dictionary<string, object?>
                {
                    ["x"] = 0,
                    ["y"] = 0,
                    ["h"] = 10,
                    ["w"] = 10,
                },
                ["title"] = "panel",
                ["type"] = "text",
                ["version"] = 0,
            }),
        });
    
        // create a dashboard using the library panel
        // `merge()` will add `libraryPanel` attribute to each library panel JSON
        // Grafana will then connect any library panels found in dashboard JSON
        var withLibraryPanel = new Grafana.Oss.Dashboard("with_library_panel", new()
        {
            ConfigJson = JsonSerializer.Serialize(new Dictionary<string, object?>
            {
                ["id"] = 12345,
                ["panels"] = new[]
                {
                    Std.Index.Merge.Invoke(new()
                    {
                        Input = new[]
                        {
                            Std.Index.Jsondecode.Invoke(new()
                            {
                                Input = dashboard.ModelJson,
                            }).Result,
                            
                            {
                                { "libraryPanel", 
                                {
                                    { "name", dashboard.Name },
                                    { "uid", dashboard.Uid },
                                } },
                            },
                        },
                    }).Result,
                },
                ["title"] = "Production Overview",
                ["tags"] = new[]
                {
                    "templated",
                },
                ["timezone"] = "browser",
                ["schemaVersion"] = 16,
                ["version"] = 0,
                ["refresh"] = "25s",
            }),
        });
    
        // dashboard_ids list attribute should contain dashboard id 12345
        var connectedToDashboard = Grafana.Oss.GetLibraryPanel.Invoke(new()
        {
            Uid = dashboard.Uid,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.grafana.oss.LibraryPanel;
    import com.pulumi.grafana.oss.LibraryPanelArgs;
    import com.pulumi.grafana.oss.OssFunctions;
    import com.pulumi.grafana.oss.inputs.GetLibraryPanelArgs;
    import com.pulumi.grafana.oss.Dashboard;
    import com.pulumi.grafana.oss.DashboardArgs;
    import com.pulumi.std.StdFunctions;
    import static com.pulumi.codegen.internal.Serialization.*;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            // create a minimal library panel inside the General folder
            var test = new LibraryPanel("test", LibraryPanelArgs.builder()
                .name("test name")
                .modelJson(serializeJson(
                    jsonObject(
                        jsonProperty("title", "test name"),
                        jsonProperty("type", "text"),
                        jsonProperty("version", 0)
                    )))
                .build());
    
            final var fromName = OssFunctions.getLibraryPanel(GetLibraryPanelArgs.builder()
                .name(test.name())
                .build());
    
            final var fromUid = OssFunctions.getLibraryPanel(GetLibraryPanelArgs.builder()
                .uid(test.uid())
                .build());
    
            // create library panels to be added to a dashboard
            var dashboard = new LibraryPanel("dashboard", LibraryPanelArgs.builder()
                .name("panel")
                .modelJson(serializeJson(
                    jsonObject(
                        jsonProperty("gridPos", jsonObject(
                            jsonProperty("x", 0),
                            jsonProperty("y", 0),
                            jsonProperty("h", 10),
                            jsonProperty("w", 10)
                        )),
                        jsonProperty("title", "panel"),
                        jsonProperty("type", "text"),
                        jsonProperty("version", 0)
                    )))
                .build());
    
            // create a dashboard using the library panel
            // `merge()` will add `libraryPanel` attribute to each library panel JSON
            // Grafana will then connect any library panels found in dashboard JSON
            var withLibraryPanel = new Dashboard("withLibraryPanel", DashboardArgs.builder()
                .configJson(serializeJson(
                    jsonObject(
                        jsonProperty("id", 12345),
                        jsonProperty("panels", jsonArray(StdFunctions.merge(Map.of("input",                     
                            StdFunctions.jsondecode(Map.of("input", dashboard.modelJson())).result(),
                            Map.of("libraryPanel", Map.ofEntries(
                                Map.entry("name", dashboard.name()),
                                Map.entry("uid", dashboard.uid())
                            )))).result())),
                        jsonProperty("title", "Production Overview"),
                        jsonProperty("tags", jsonArray("templated")),
                        jsonProperty("timezone", "browser"),
                        jsonProperty("schemaVersion", 16),
                        jsonProperty("version", 0),
                        jsonProperty("refresh", "25s")
                    )))
                .build());
    
            // dashboard_ids list attribute should contain dashboard id 12345
            final var connectedToDashboard = OssFunctions.getLibraryPanel(GetLibraryPanelArgs.builder()
                .uid(dashboard.uid())
                .build());
    
        }
    }
    
    resources:
      # create a minimal library panel inside the General folder
      test:
        type: grafana:oss:LibraryPanel
        properties:
          name: test name
          modelJson:
            fn::toJSON:
              title: test name
              type: text
              version: 0
      # create library panels to be added to a dashboard
      dashboard:
        type: grafana:oss:LibraryPanel
        properties:
          name: panel
          modelJson:
            fn::toJSON:
              gridPos:
                x: 0
                y: 0
                h: 10
                w: 10
              title: panel
              type: text
              version: 0
      # create a dashboard using the library panel
      # // `merge()` will add `libraryPanel` attribute to each library panel JSON
      # // Grafana will then connect any library panels found in dashboard JSON
      withLibraryPanel:
        type: grafana:oss:Dashboard
        name: with_library_panel
        properties:
          configJson:
            fn::toJSON:
              id: 12345
              panels:
                - fn::invoke:
                    function: std:merge
                    arguments:
                      input:
                        - fn::invoke:
                            function: std:jsondecode
                            arguments:
                              input: ${dashboard.modelJson}
                            return: result
                        - libraryPanel:
                            name: ${dashboard.name}
                            uid: ${dashboard.uid}
                    return: result
              title: Production Overview
              tags:
                - templated
              timezone: browser
              schemaVersion: 16
              version: 0
              refresh: 25s
    variables:
      fromName:
        fn::invoke:
          function: grafana:oss:getLibraryPanel
          arguments:
            name: ${test.name}
      fromUid:
        fn::invoke:
          function: grafana:oss:getLibraryPanel
          arguments:
            uid: ${test.uid}
      # dashboard_ids list attribute should contain dashboard id 12345
      connectedToDashboard:
        fn::invoke:
          function: grafana:oss:getLibraryPanel
          arguments:
            uid: ${dashboard.uid}
    

    Using getLibraryPanel

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getLibraryPanel(args: GetLibraryPanelArgs, opts?: InvokeOptions): Promise<GetLibraryPanelResult>
    function getLibraryPanelOutput(args: GetLibraryPanelOutputArgs, opts?: InvokeOptions): Output<GetLibraryPanelResult>
    def get_library_panel(name: Optional[str] = None,
                          org_id: Optional[str] = None,
                          uid: Optional[str] = None,
                          opts: Optional[InvokeOptions] = None) -> GetLibraryPanelResult
    def get_library_panel_output(name: Optional[pulumi.Input[str]] = None,
                          org_id: Optional[pulumi.Input[str]] = None,
                          uid: Optional[pulumi.Input[str]] = None,
                          opts: Optional[InvokeOptions] = None) -> Output[GetLibraryPanelResult]
    func LookupLibraryPanel(ctx *Context, args *LookupLibraryPanelArgs, opts ...InvokeOption) (*LookupLibraryPanelResult, error)
    func LookupLibraryPanelOutput(ctx *Context, args *LookupLibraryPanelOutputArgs, opts ...InvokeOption) LookupLibraryPanelResultOutput

    > Note: This function is named LookupLibraryPanel in the Go SDK.

    public static class GetLibraryPanel 
    {
        public static Task<GetLibraryPanelResult> InvokeAsync(GetLibraryPanelArgs args, InvokeOptions? opts = null)
        public static Output<GetLibraryPanelResult> Invoke(GetLibraryPanelInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetLibraryPanelResult> getLibraryPanel(GetLibraryPanelArgs args, InvokeOptions options)
    public static Output<GetLibraryPanelResult> getLibraryPanel(GetLibraryPanelArgs args, InvokeOptions options)
    
    fn::invoke:
      function: grafana:oss/getLibraryPanel:getLibraryPanel
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Name string
    Name of the library panel.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Uid string
    The unique identifier (UID) of the library panel.
    Name string
    Name of the library panel.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Uid string
    The unique identifier (UID) of the library panel.
    name String
    Name of the library panel.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    uid String
    The unique identifier (UID) of the library panel.
    name string
    Name of the library panel.
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    uid string
    The unique identifier (UID) of the library panel.
    name str
    Name of the library panel.
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    uid str
    The unique identifier (UID) of the library panel.
    name String
    Name of the library panel.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    uid String
    The unique identifier (UID) of the library panel.

    getLibraryPanel Result

    The following output properties are available:

    Created string
    Timestamp when the library panel was created.
    DashboardIds List<int>
    Numerical IDs of Grafana dashboards containing the library panel.
    Description string
    Description of the library panel.
    FolderName string
    Name of the folder containing the library panel.
    FolderUid string
    Unique ID (UID) of the folder containing the library panel.
    Id string
    The provider-assigned unique ID for this managed resource.
    ModelJson string
    The JSON model for the library panel.
    PanelId int
    The numeric ID of the library panel computed by Grafana.
    Type string
    Type of the library panel (eg. text).
    Updated string
    Timestamp when the library panel was last modified.
    Version int
    Version of the library panel.
    Name string
    Name of the library panel.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Uid string
    The unique identifier (UID) of the library panel.
    Created string
    Timestamp when the library panel was created.
    DashboardIds []int
    Numerical IDs of Grafana dashboards containing the library panel.
    Description string
    Description of the library panel.
    FolderName string
    Name of the folder containing the library panel.
    FolderUid string
    Unique ID (UID) of the folder containing the library panel.
    Id string
    The provider-assigned unique ID for this managed resource.
    ModelJson string
    The JSON model for the library panel.
    PanelId int
    The numeric ID of the library panel computed by Grafana.
    Type string
    Type of the library panel (eg. text).
    Updated string
    Timestamp when the library panel was last modified.
    Version int
    Version of the library panel.
    Name string
    Name of the library panel.
    OrgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    Uid string
    The unique identifier (UID) of the library panel.
    created String
    Timestamp when the library panel was created.
    dashboardIds List<Integer>
    Numerical IDs of Grafana dashboards containing the library panel.
    description String
    Description of the library panel.
    folderName String
    Name of the folder containing the library panel.
    folderUid String
    Unique ID (UID) of the folder containing the library panel.
    id String
    The provider-assigned unique ID for this managed resource.
    modelJson String
    The JSON model for the library panel.
    panelId Integer
    The numeric ID of the library panel computed by Grafana.
    type String
    Type of the library panel (eg. text).
    updated String
    Timestamp when the library panel was last modified.
    version Integer
    Version of the library panel.
    name String
    Name of the library panel.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    uid String
    The unique identifier (UID) of the library panel.
    created string
    Timestamp when the library panel was created.
    dashboardIds number[]
    Numerical IDs of Grafana dashboards containing the library panel.
    description string
    Description of the library panel.
    folderName string
    Name of the folder containing the library panel.
    folderUid string
    Unique ID (UID) of the folder containing the library panel.
    id string
    The provider-assigned unique ID for this managed resource.
    modelJson string
    The JSON model for the library panel.
    panelId number
    The numeric ID of the library panel computed by Grafana.
    type string
    Type of the library panel (eg. text).
    updated string
    Timestamp when the library panel was last modified.
    version number
    Version of the library panel.
    name string
    Name of the library panel.
    orgId string
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    uid string
    The unique identifier (UID) of the library panel.
    created str
    Timestamp when the library panel was created.
    dashboard_ids Sequence[int]
    Numerical IDs of Grafana dashboards containing the library panel.
    description str
    Description of the library panel.
    folder_name str
    Name of the folder containing the library panel.
    folder_uid str
    Unique ID (UID) of the folder containing the library panel.
    id str
    The provider-assigned unique ID for this managed resource.
    model_json str
    The JSON model for the library panel.
    panel_id int
    The numeric ID of the library panel computed by Grafana.
    type str
    Type of the library panel (eg. text).
    updated str
    Timestamp when the library panel was last modified.
    version int
    Version of the library panel.
    name str
    Name of the library panel.
    org_id str
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    uid str
    The unique identifier (UID) of the library panel.
    created String
    Timestamp when the library panel was created.
    dashboardIds List<Number>
    Numerical IDs of Grafana dashboards containing the library panel.
    description String
    Description of the library panel.
    folderName String
    Name of the folder containing the library panel.
    folderUid String
    Unique ID (UID) of the folder containing the library panel.
    id String
    The provider-assigned unique ID for this managed resource.
    modelJson String
    The JSON model for the library panel.
    panelId Number
    The numeric ID of the library panel computed by Grafana.
    type String
    Type of the library panel (eg. text).
    updated String
    Timestamp when the library panel was last modified.
    version Number
    Version of the library panel.
    name String
    Name of the library panel.
    orgId String
    The Organization ID. If not set, the Org ID defined in the provider block will be used.
    uid String
    The unique identifier (UID) of the library panel.

    Package Details

    Repository
    grafana pulumiverse/pulumi-grafana
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the grafana Terraform Provider.
    grafana logo
    Grafana v2.18.0 published on Wednesday, Dec 3, 2025 by pulumiverse
      Meet Neo: Your AI Platform Teammate