Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bf81752
vendor: remove Vendor Folder
mikeodr Oct 1, 2025
fd6f975
cmd: add command-line flags for metrics server address and port
mikeodr Oct 1, 2025
58058a4
go.mod: update go version
mikeodr Oct 1, 2025
975080c
.github: add dependabot updates
mikeodr Oct 1, 2025
ee53536
.gitignore: add binary and nix result link
mikeodr Oct 1, 2025
66d9587
Remove vendor from ci
mikeodr Oct 1, 2025
ef9daaf
Update dependabot.yml
mikeodr Oct 1, 2025
899f7d8
deps(deps): bump github.com/gorilla/websocket from 1.5.0 to 1.5.3
dependabot[bot] Oct 1, 2025
3280299
.github: update publish target
mikeodr Oct 1, 2025
3dde1ee
.github: remove publish
mikeodr Oct 1, 2025
14cd4a1
Merge pull request #4 from mikeodr/dependabot/go_modules/github.com/g…
mikeodr Oct 1, 2025
0e93138
ci(deps): bump actions/checkout from 4 to 5
dependabot[bot] Oct 1, 2025
522a0f1
deps(deps): bump github.com/prometheus/client_golang
dependabot[bot] Oct 1, 2025
b2576bc
Merge pull request #1 from mikeodr/dependabot/github_actions/actions/…
mikeodr Oct 1, 2025
919ffc4
Merge pull request #2 from mikeodr/dependabot/go_modules/github.com/p…
mikeodr Oct 1, 2025
18bce9c
.github: update CI go version
mikeodr Oct 1, 2025
68f8f56
ci(deps): bump actions/setup-go from 5 to 6
dependabot[bot] Oct 1, 2025
827c9b9
Merge pull request #3 from mikeodr/dependabot/github_actions/actions/…
mikeodr Oct 1, 2025
4a317db
flake: add initial Nix flake
mikeodr Oct 1, 2025
eda95f5
Merge pull request #5 from mikeodr/mikeodr/add-nix-flake
mikeodr Oct 1, 2025
f454f78
flake.nix: add environmentFile option (#6)
mikeodr Oct 2, 2025
cb84c80
ci(deps): bump actions/upload-artifact from 4 to 5 (#7)
dependabot[bot] Oct 27, 2025
578263e
ci(deps): bump actions/checkout from 5 to 6 (#8)
dependabot[bot] Nov 24, 2025
3b9920e
ci(deps): bump actions/upload-artifact from 5 to 6 (#9)
dependabot[bot] Dec 15, 2025
133b428
flake.nix: make exporter service require plex
mikeodr Jan 24, 2026
228c08a
ci(deps): bump release-drafter/release-drafter from 6 to 7 (#11)
dependabot[bot] Mar 16, 2026
79e7988
ci(deps): bump actions/upload-artifact from 6 to 7 (#10)
dependabot[bot] Mar 16, 2026
f271f2e
flake: update inputs use go_1_26
mikeodr Apr 4, 2026
15d5751
.github: use govulcheck, not dependabot
mikeodr Apr 13, 2026
991366f
flake: update systemd job (#12)
mikeodr Apr 13, 2026
6932f76
.github,go.mod: update go version (#13)
mikeodr Apr 14, 2026
fc82cf5
flake,go.mod: update to go 1.26.2
mikeodr Apr 23, 2026
f83fbef
flake,go.mod: update go to 1.26.3 (#14)
mikeodr May 12, 2026
9145b75
flake,go: update to go 1.26.4
mikeodr Jun 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ jobs:
- goos: windows
goarch: amd64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: 1.23.0
go-version-file: go.mod
cache: false
- run: go build -mod vendor -o ./bin/prometheus-plex-exporter ./cmd/prometheus-plex-exporter
- run: go build -o ./bin/prometheus-plex-exporter ./cmd/prometheus-plex-exporter
env:
CGO_ENABLED: "0"
GOOS: ${{ matrix.goos }}
Expand All @@ -41,7 +41,7 @@ jobs:
CGO_ENABLED: "0"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v7
with:
name: prometheus-plex-exporter-${{ matrix.goos }}-${{ matrix.goarch}}
path: ./bin
Expand All @@ -53,7 +53,7 @@ jobs:
permissions:
contents: write
steps:
- uses: release-drafter/release-drafter@v6
- uses: release-drafter/release-drafter@v7
with:
disable-autolabeler: true
env:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/govulncheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: govulncheck

on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: "0 9 * * 2" # Tuesdays at 09:00 UTC

permissions:
contents: read

jobs:
govulncheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: false
- run: go install golang.org/x/vuln/cmd/govulncheck@latest
- run: govulncheck ./...
36 changes: 0 additions & 36 deletions .github/workflows/publish.yml

This file was deleted.

7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
vendor/

# Go workspace file
go.work*
Expand All @@ -25,4 +25,7 @@ go.work*
.vscode
.env
bin/
tmp/
tmp/

result
prometheus-plex-exporter
13 changes: 9 additions & 4 deletions cmd/prometheus-plex-exporter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"context"
"errors"
"flag"
"fmt"
"net/http"
"os"
"os/signal"
Expand All @@ -17,15 +19,18 @@ import (
"github.com/grafana/plexporter/pkg/plex"
)

const (
MetricsServerAddr = ":9000"
)

var (
log = kitlog.NewLogfmtLogger(kitlog.NewSyncWriter(os.Stderr))

MetricsServerBindAddr = flag.String("bind-addr", "", "The address the metrics endpoint binds to.")
MetricsServerPort = flag.Int("port", 9000, "The port the metrics endpoint binds to.")
)

func main() {
flag.Parse()

MetricsServerAddr := fmt.Sprintf("%s:%d", *MetricsServerBindAddr, *MetricsServerPort)

ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer cancel()

Expand Down
43 changes: 43 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

148 changes: 148 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
{
description = "prometheus exporter for plex media server";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
systems.url = "github:nix-systems/default";
};

outputs = {
self,
nixpkgs,
systems,
}: let
eachSystem = f: nixpkgs.lib.genAttrs (import systems) (s: f nixpkgs.legacyPackages.${s});
in {
packages = eachSystem (pkgs: {
default = (pkgs.buildGoModule.override {go = pkgs.go_1_26;}) {
pname = "prometheus-plex-exporter";
version =
if (self ? shortRev)
then self.shortRev
else "dev";
subPackages = [
"cmd/prometheus-plex-exporter"
];
src = ./.;
vendorHash = "sha256-RhP9bp2GQd5SyAQ8IzpOiUhPEZqkxhmcEESC9E6AfRM=";
meta.mainProgram = "prometheus-plex-exporter";
};
});

overlays.default = final: prev: {
prometheus-plex-exporter = self.packages.${prev.stdenv.hostPlatform.system}.default;
};

nixosModules.default = {
config,
lib,
pkgs,
...
}: let
inherit
(lib)
getExe
mkEnableOption
mkIf
mkOption
optional
optionalString
toString
;

inherit
(lib.types)
bool
nullOr
package
path
port
str
;

cfg = config.services.prometheus-plex-exporter;
in {
options.services.prometheus-plex-exporter = {
enable = mkEnableOption "prometheus exporter for plex media server";

package = mkOption {
type = package;
default = pkgs.prometheus-plex-exporter;
description = "Package to use for prometheus-plex-exporter.";
};

bindAddress = mkOption {
type = str;
default = "";
description = "Address to bind to, defaults to all interfaces.";
};

port = mkOption {
type = port;
default = 9000;
};

user = mkOption {
type = str;
default = "nobody";
};

group = mkOption {
type = str;
default = "nogroup";
};

plexServer = mkOption {
type = str;
default = "http://localhost:32400";
description = "The URL of the Plex server to monitor. Ignored if environmentFile is set.";
};

plexToken = mkOption {
type = str;
description = "The Plex token to use to authenticate with the Plex server. Ignored if environmentFile is set.";
};

environmentFile = mkOption {
type = nullOr path;
default = null;
description = "Path to a file containing environment variables to set for the service. Setting this ignores plexServer and plexToken options. Must set PLEX_SERVER and PLEX_TOKEN variables.";
};

openFirewall = mkOption {
type = bool;
default = false;
description = "Whether to open the firewall for the prometheus-plex-exporter port.";
};
};

config = mkIf cfg.enable {
nixpkgs.overlays = [self.overlays.default];
networking.firewall.allowedTCPPorts = optional cfg.openFirewall [cfg.port];

systemd.services.prometheus-plex-exporter = {
description = "Prometheus Plex Exporter";
after = ["network.target" "plex.service"];
requires = ["plex.service"];
wants = ["network.target"];
environment = mkIf (cfg.environmentFile == null) {
PLEX_SERVER = cfg.plexServer;
PLEX_TOKEN = cfg.plexToken;
};
serviceConfig = {
EnvironmentFile = mkIf (cfg.environmentFile != null) cfg.environmentFile;
User = "${cfg.user}";
Group = "${cfg.group}";
ExecStart = ''
${getExe cfg.package} \
${optionalString (cfg.bindAddress != "") "--bind-addr ${cfg.bindAddress}"} \
${optionalString (cfg.port != 9000) ("--port " + toString cfg.port)}
'';
Restart = "on-failure";
};
wantedBy = ["multi-user.target"];
};
};
};
};
}
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
module github.com/grafana/plexporter

go 1.23
go 1.26.4

require (
github.com/go-kit/log v0.2.1
github.com/gorilla/websocket v1.5.0
github.com/gorilla/websocket v1.5.3
github.com/jrudio/go-plex-client v0.0.0-20220428052413-e5b4386beb17
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/client_golang v1.23.2
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
google.golang.org/protobuf v1.33.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
golang.org/x/sys v0.35.0 // indirect
google.golang.org/protobuf v1.36.8 // indirect
)

// Replace for fix: https://github.com/jrudio/go-plex-client/pull/56
Expand Down
Loading