Code Monkey home page Code Monkey logo

memcached_exporter's Introduction

Memcached Exporter for Prometheus Build Status

Docker Repository on Quay Docker Pulls

A memcached exporter for Prometheus.

Building

The memcached exporter exports metrics from a memcached server for consumption by Prometheus. The server is specified as --memcached.address flag to the program (default is localhost:11211).

By default the memcache_exporter serves on port 0.0.0.0:9150 at /metrics:

make
./memcached_exporter

Alternatively a Dockerfile is supplied:

docker run -p 9150:9150 quay.io/prometheus/memcached-exporter:latest

Collectors

The exporter collects a number of statistics from the server:

# HELP memcached_accepting_conns The Memcached server is currently accepting new connections.
# TYPE memcached_accepting_conns gauge
# HELP memcached_commands_total Total number of all requests broken down by command (get, set, etc.) and status.
# TYPE memcached_commands_total counter
# HELP memcached_connections_listener_disabled_total Number of times that memcached has hit its connections limit and disabled its listener.
# TYPE memcached_connections_listener_disabled_total counter
# HELP memcached_connections_total Total number of connections opened since the server started running.
# TYPE memcached_connections_total counter
# HELP memcached_connections_yielded_total Total number of connections yielded running due to hitting the memcached's -R limit.
# TYPE memcached_connections_yielded_total counter
# HELP memcached_current_bytes Current number of bytes used to store items.
# TYPE memcached_current_bytes gauge
# HELP memcached_current_connections Current number of open connections.
# TYPE memcached_current_connections gauge
# HELP memcached_current_items Current number of items stored by this instance.
# TYPE memcached_current_items gauge
# HELP memcached_items_evicted_total Total number of valid items removed from cache to free memory for new items.
# TYPE memcached_items_evicted_total counter
# HELP memcached_items_reclaimed_total Total number of times an entry was stored using memory from an expired entry.
# TYPE memcached_items_reclaimed_total counter
# HELP memcached_items_total Total number of items stored during the life of this instance.
# TYPE memcached_items_total counter
# HELP memcached_limit_bytes Number of bytes this server is allowed to use for storage.
# TYPE memcached_limit_bytes gauge
# HELP memcached_lru_crawler_enabled Whether the LRU crawler is enabled.
# TYPE memcached_lru_crawler_enabled gauge
# HELP memcached_lru_crawler_hot_max_factor Set idle age of HOT LRU to COLD age * this
# TYPE memcached_lru_crawler_hot_max_factor gauge
# HELP memcached_lru_crawler_hot_percent Percent of slab memory reserved for HOT LRU.
# TYPE memcached_lru_crawler_hot_percent gauge
# HELP memcached_lru_crawler_items_checked_total Total items examined by LRU Crawler.
# TYPE memcached_lru_crawler_items_checked_total counter
# HELP memcached_lru_crawler_maintainer_thread Split LRU mode and background threads.
# TYPE memcached_lru_crawler_maintainer_thread gauge
# HELP memcached_lru_crawler_moves_to_cold_total Total number of items moved from HOT/WARM to COLD LRU's.
# TYPE memcached_lru_crawler_moves_to_cold_total counter
# HELP memcached_lru_crawler_moves_to_warm_total Total number of items moved from COLD to WARM LRU.
# TYPE memcached_lru_crawler_moves_to_warm_total counter
# HELP memcached_lru_crawler_moves_within_lru_total Total number of items reshuffled within HOT or WARM LRU's.
# TYPE memcached_lru_crawler_moves_within_lru_total counter
# HELP memcached_lru_crawler_reclaimed_total Total items freed by LRU Crawler.
# TYPE memcached_lru_crawler_reclaimed_total counter
# HELP memcached_lru_crawler_sleep Microseconds to sleep between LRU crawls.
# TYPE memcached_lru_crawler_sleep gauge
# HELP memcached_lru_crawler_starts_total Times an LRU crawler was started.
# TYPE memcached_lru_crawler_starts_total counter
# HELP memcached_lru_crawler_to_crawl Max items to crawl per slab per run.
# TYPE memcached_lru_crawler_to_crawl gauge
# HELP memcached_lru_crawler_warm_max_factor Set idle age of WARM LRU to COLD age * this
# TYPE memcached_lru_crawler_warm_max_factor gauge
# HELP memcached_lru_crawler_warm_percent Percent of slab memory reserved for WARM LRU.
# TYPE memcached_lru_crawler_warm_percent gauge
# HELP memcached_malloced_bytes Number of bytes of memory allocated to slab pages.
# TYPE memcached_malloced_bytes gauge
# HELP memcached_max_connections Maximum number of clients allowed.
# TYPE memcached_max_connections gauge
# HELP memcached_read_bytes_total Total number of bytes read by this server from network.
# TYPE memcached_read_bytes_total counter
# HELP memcached_slab_chunk_size_bytes Number of bytes allocated to each chunk within this slab class.
# TYPE memcached_slab_chunk_size_bytes gauge
# HELP memcached_slab_chunks_free Number of chunks not yet allocated items.
# TYPE memcached_slab_chunks_free gauge
# HELP memcached_slab_chunks_free_end Number of free chunks at the end of the last allocated page.
# TYPE memcached_slab_chunks_free_end gauge
# HELP memcached_slab_chunks_per_page Number of chunks within a single page for this slab class.
# TYPE memcached_slab_chunks_per_page gauge
# HELP memcached_slab_chunks_used Number of chunks allocated to an item.
# TYPE memcached_slab_chunks_used gauge
# HELP memcached_slab_cold_items Number of items presently stored in the COLD LRU.
# TYPE memcached_slab_cold_items gauge
# HELP memcached_slab_commands_total Total number of all requests broken down by command (get, set, etc.) and status per slab.
# TYPE memcached_slab_commands_total counter
# HELP memcached_slab_current_chunks Number of chunks allocated to this slab class.
# TYPE memcached_slab_current_chunks gauge
# HELP memcached_slab_current_items Number of items currently stored in this slab class.
# TYPE memcached_slab_current_items gauge
# HELP memcached_slab_current_pages Number of pages allocated to this slab class.
# TYPE memcached_slab_current_pages gauge
# HELP memcached_slab_hot_age_seconds Age of the oldest item in HOT LRU.
# TYPE memcached_slab_hot_age_seconds gauge
# HELP memcached_slab_hot_items Number of items presently stored in the HOT LRU.
# TYPE memcached_slab_hot_items gauge
# HELP memcached_slab_items_age_seconds Number of seconds the oldest item has been in the slab class.
# TYPE memcached_slab_items_age_seconds gauge
# HELP memcached_slab_items_crawler_reclaimed_total Number of items freed by the LRU Crawler.
# TYPE memcached_slab_items_crawler_reclaimed_total counter
# HELP memcached_slab_items_evicted_nonzero_total Total number of times an item which had an explicit expire time set had to be evicted from the LRU before it expired.
# TYPE memcached_slab_items_evicted_nonzero_total counter
# HELP memcached_slab_items_evicted_time_seconds Seconds since the last access for the most recent item evicted from this class.
# TYPE memcached_slab_items_evicted_time_seconds counter
# HELP memcached_slab_items_evicted_total Total number of times an item had to be evicted from the LRU before it expired.
# TYPE memcached_slab_items_evicted_total counter
# HELP memcached_slab_items_evicted_unfetched_total Total nmber of items evicted and never fetched.
# TYPE memcached_slab_items_evicted_unfetched_total counter
# HELP memcached_slab_items_expired_unfetched_total Total number of valid items evicted from the LRU which were never touched after being set.
# TYPE memcached_slab_items_expired_unfetched_total counter
# HELP memcached_slab_items_moves_to_cold Number of items moved from HOT or WARM into COLD.
# TYPE memcached_slab_items_moves_to_cold counter
# HELP memcached_slab_items_moves_to_warm Number of items moves from COLD into WARM.
# TYPE memcached_slab_items_moves_to_warm counter
# HELP memcached_slab_items_moves_within_lru Number of times active items were bumped within HOT or WARM.
# TYPE memcached_slab_items_moves_within_lru counter
# HELP memcached_slab_items_outofmemory_total Total number of items for this slab class that have triggered an out of memory error.
# TYPE memcached_slab_items_outofmemory_total counter
# HELP memcached_slab_items_reclaimed_total Total number of items reclaimed.
# TYPE memcached_slab_items_reclaimed_total counter
# HELP memcached_slab_items_tailrepairs_total Total number of times the entries for a particular ID need repairing.
# TYPE memcached_slab_items_tailrepairs_total counter
# HELP memcached_slab_lru_hits_total Number of get_hits to the LRU.
# TYPE memcached_slab_lru_hits_total counter
# HELP memcached_slab_mem_requested_bytes Number of bytes of memory actual items take up within a slab.
# TYPE memcached_slab_mem_requested_bytes counter
# HELP memcached_slab_warm_age_seconds Age of the oldest item in HOT LRU.
# TYPE memcached_slab_warm_age_seconds gauge
# HELP memcached_slab_warm_items Number of items presently stored in the WARM LRU.
# TYPE memcached_slab_warm_items gauge
# HELP memcached_time_seconds current UNIX time according to the server.
# TYPE memcached_time_seconds gauge
# HELP memcached_up Could the memcached server be reached.
# TYPE memcached_up gauge
# HELP memcached_uptime_seconds Number of seconds since the server started.
# TYPE memcached_uptime_seconds counter
# HELP memcached_version The version of this memcached server.
# TYPE memcached_version gauge
# HELP memcached_written_bytes_total Total number of bytes sent by this server to network.
# TYPE memcached_written_bytes_total counter

There is also optional support to export metrics about the memcached process itself by setting the --memcached.pid-file <path> flag. If the memcached_exporter process has the rights to read /proc information of the memcached process, then the following metrics will be exported additionally.

# HELP memcached_process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE memcached_process_cpu_seconds_total counter
# HELP memcached_process_max_fds Maximum number of open file descriptors.
# TYPE memcached_process_max_fds gauge
# HELP memcached_process_open_fds Number of open file descriptors.
# TYPE memcached_process_open_fds gauge
# HELP memcached_process_resident_memory_bytes Resident memory size in bytes.
# TYPE memcached_process_resident_memory_bytes gauge
# HELP memcached_process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE memcached_process_start_time_seconds gauge
# HELP memcached_process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE memcached_process_virtual_memory_bytes gauge

TLS and basic authentication

The Memcached Exporter supports TLS and basic authentication.

To use TLS and/or basic authentication, you need to pass a configuration file using the --web.config.file parameter. The format of the file is described in the exporter-toolkit repository.

To use TLS for connections to memcached, use the --memcached.tls.* flags. See memcached_exporter --help for details.

Multi-target

The exporter also supports the multi-target pattern on the /scrape endpoint. Example:

curl `localhost:9150/scrape?target=memcached-host.company.com:11211

An example configuration using prometheus-elasticache-sd:

scrape_configs:
  - job_name: "memcached_exporter_targets"
    file_sd_configs:
    - files:
        - /path/to/elasticache.json  # File created by service discovery
    metrics_path: /scrape
    relabel_configs:
      # Filter for memcached cache nodes
      - source_labels: [__meta_elasticache_engine]
        regex: memcached
        action: keep
      # Build Memcached URL to use as target parameter for the exporter
      - source_labels:
          - __meta_elasticache_endpoint_address
          - __meta_elasticache_endpoint_port
        replacement: $1
        separator: ':'
        target_label: __param_target
      # Use Memcached URL as instance label
      - source_labels: [__param_target]
        target_label: instance
      # Set exporter address
      - target_label: __address__
        replacement: memcached-exporter-service.company.com:9151

If you are running solely for multi-target start the exporter with --memcached.address="" to avoid attempting to connect to a non existing memcached host, example:

./memcached-exporter --memcached.address=""

memcached_exporter's People

Contributors

beorn7 avatar blkperl avatar dannykopping avatar dependabot[bot] avatar der-eismann avatar dimitrovvlado avatar elukey avatar f110 avatar filippog avatar gdvalle avatar grobie avatar gvengel avatar inosato avatar ipstatic avatar junjihashimoto avatar mateusduboli avatar matthiasr avatar mguegan avatar prombot avatar rfratto avatar roidelapluie avatar sdurrheimer avatar sh-cho avatar simonpasquier avatar snapbug avatar spiraltaap avatar superq avatar tnosaj avatar yeya24 avatar zoidyzoidzoid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

memcached_exporter's Issues

missing stats

Using:

  • prom/memcached-exporter:master (also tried v.0.3.0)
  • memcached:1.5.2
  • k8s 1.7

After successful installation I am missing lot of memcached related stats:

curl memcached-exporter.ops:9150/metrics | grep memcached
# HELP memcached_up Could the memcached server be reached.
# TYPE memcached_up gauge
memcached_up 1

curl memcached-exporter.ops:9150/metrics | wc -l
126

echo -e 'stats' | nc cache-memcached.prod 11211 | grep version
STAT version 1.5.2

how to get metrics about latency

I want to get some indicators about latency. Does the exporter have any indicators about latency, or what should I do to get these indicators

Support Unix protocol

Start memcached with unix params
mecached -s /var/run/memcached.sock -a 755

Start exporter (but not work).
memcached_exporter --memcached.address /var/run/memcached.sock

More slab metrics for Memcached 1.5.x

Hi!

I am testing the 0.6 release with Memcache 1.5.6 (Debian Buster) and I noticed that some slab metrics are not rendered:

STAT items:63:number_hot 384
STAT items:63:number_warm 543
STAT items:63:number_cold 1677
STAT items:63:age_hot 25484
STAT items:63:age_warm 128596
STAT items:63:direct_reclaims 0
STAT items:63:hits_to_hot 542290
STAT items:63:hits_to_warm 175335
STAT items:63:hits_to_cold 4970
STAT items:63:hits_to_temp 0

number_hot             Number of items presently stored in the HOT LRU.
number_warm            Number of items presently stored in the WARM LRU.
number_cold            Number of items presently stored in the COLD LRU.
number_temp            Number of items presently stored in the TEMPORARY LRU.
age_hot                Age of the oldest item in HOT LRU.
age_warm               Age of the oldest item in WARM LRU.
direct_reclaims        Number of times worker threads had to directly pull LRU tails to find memory for a new item.
hits_to_hot
hits_to_warm
hits_to_cold
hits_to_temp           Number of get_hits to each sub-LRU.

Are these metrics not included on purpose or just waiting for a pull request (I can send one in case) ? :)

Build fails: cannot use s (type memcache.Stats) as type map

$ go get -v
github.com/Snapbug/gomemcache (download)
github.com/prometheus/client_golang (download)
github.com/beorn7/perks (download)
github.com/golang/protobuf (download)
github.com/prometheus/client_model (download)
github.com/prometheus/common (download)
github.com/matttproud/golang_protobuf_extensions (download)
github.com/prometheus/procfs (download)
github.com/prometheus/log (download)
github.com/Sirupsen/logrus (download)
github.com/Snapbug/gomemcache/memcache
github.com/beorn7/perks/quantile
github.com/golang/protobuf/proto
github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg
github.com/prometheus/common/model
github.com/prometheus/procfs
github.com/Sirupsen/logrus
github.com/prometheus/log
github.com/prometheus/client_model/go
github.com/matttproud/golang_protobuf_extensions/pbutil
github.com/prometheus/common/expfmt
github.com/prometheus/client_golang/prometheus
_/home/niko/memcached_exporter
# _/home/niko/memcached_exporter
./main.go:171: cannot use s (type memcache.Stats) as type map[string]string in argument to parse
./main.go:172: invalid operation: s["version"] (type memcache.Stats does not support indexing)
./main.go:175: cannot use s (type memcache.Stats) as type map[string]string in argument to parse
./main.go:176: cannot use s (type memcache.Stats) as type map[string]string in argument to parse
./main.go:178: cannot use s (type memcache.Stats) as type map[string]string in argument to parse
./main.go:179: cannot use s (type memcache.Stats) as type map[string]string in argument to parse
./main.go:183: invalid operation: s["cmd_set"] (type memcache.Stats does not support indexing)
./main.go:184: cannot use s (type memcache.Stats) as type map[string]string in argument to sum
./main.go:190: invalid operation: s["cmd_set"] (type memcache.Stats does not support indexing)
./main.go:194: cannot use s (type memcache.Stats) as type map[string]string in argument to parse
./main.go:194: too many errors

Documentation inconsistency

Hello.

In the READMEs in the quay and docker registries the default port is listed as 9106, but in GitHub, and when running, it's 9150.

"By default the memcache_exporter serves on port 0.0.0.0:9106 at /metrics"
https://quay.io/repository/prometheus/memcached-exporter?tab=info
https://hub.docker.com/r/prom/memcached-exporter

"By default the memcache_exporter serves on port 0.0.0.0:9150 at /metrics:"
https://github.com/prometheus/memcached_exporter

Port 9150 is used throughout the code base and so should be the correct one. I can't find 9106 in the repo otherwise I would have raised a PR to fix the docs.

Thank you for your time.

what version of memcached this exporter support?

Hi,
currently im using memcached version 1.2.2.
does this version of memcached supported?

when i run the exporter it show this logs
level=info ts=2021-02-18T09:52:28.571Z caller=main.go:49 msg="Starting memcached_exporter" version="(version=0.8.0, branch=HEAD, revision=3d8ce192c21319731f1ac784af16a72468dcca5d)" level=info ts=2021-02-18T09:52:28.571Z caller=main.go:50 msg="Build context" context="(go=go1.15.5, user=root@5ba0dc63dc36, date=20201204-19:29:03)" level=info ts=2021-02-18T09:52:28.572Z caller=main.go:84 msg="Listening on address" address=:9150 level=error ts=2021-02-18T09:52:52.287Z caller=exporter.go:582 msg="Could not query stats settings" err="memcache: unexpected stats line format \"ERROR\\r\\n\"" level=error ts=2021-02-18T09:52:52.287Z caller=exporter.go:653 msg="Failed to parse cas" err="key not found" level=error ts=2021-02-18T09:52:52.287Z caller=exporter.go:738 msg="Failed to parse set" err="key not found" level=error ts=2021-02-18T09:52:52.287Z caller=exporter.go:738 msg="Failed to parse set" err="key not found" level=error ts=2021-02-18T09:52:52.287Z caller=exporter.go:738 msg="Failed to parse set" err="key not found" level=error ts=2021-02-18T09:52:52.288Z caller=exporter.go:738 msg="Failed to parse set" err="key not found"

Hi,I had a problem with memcached-exporter

Hi,I tried memcached in version 1.4.25 and 1.6.9, but I couldn't monitor the data. I made sure that I followed the document specification,Ubuntu16.04LTS+[memcached1.4.25| memcached1.6.9]+memcached-exporter0.9.
In the IP address: 9150 port, i can see some data, but they are useless data
01
02
Please give me some good suggestions. Thank you very much!!!

Does it work with "mcrouter"?

Does "memcached_exporter" work with "mcrouter"?

I am using the following config to mcrouter:

{
  "pools": {
    "A": {
      "servers": [
        "memcached-node1:11211",
        "memcached-node2:11211"
      ]
    }
  },
  "route": "PoolRoute|A"
}

Metric memcached_up is always 0

Security vulnerability in golang.org/x/net package

The currently used golang.org/x/net package version 0.4.0 has security vulnerability (see the report below):

2023-02-20T14:11:18.627+0100    DEBUG    Severities: ["UNKNOWN" "LOW" "MEDIUM" "HIGH" "CRITICAL"]
2023-02-20T14:11:18.630+0100    DEBUG    cache dir:  /root/.cache/trivy
2023-02-20T14:11:18.631+0100    DEBUG    DB update was skipped because the local DB is the latest
2023-02-20T14:11:18.631+0100    DEBUG    DB Schema: 2, UpdatedAt: 2023-02-20 12:07:57.25634111 +0000 UTC, NextUpdate: 2023-02-20 18:07:57.25634021 +0000 UTC, DownloadedAt: 2023-02-20 12:29:01.661009384 +0000 UTC
2023-02-20T14:11:18.631+0100    INFO     Vulnerability scanning is enabled
2023-02-20T14:11:18.631+0100    DEBUG    Vulnerability type:  [os library]
2023-02-20T14:11:18.631+0100    INFO     Secret scanning is enabled
2023-02-20T14:11:18.631+0100    INFO     If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2023-02-20T14:11:18.631+0100    INFO     Please see also https://aquasecurity.github.io/trivy/v0.37/docs/secret/scanning/#recommendation for faster secret detection
2023-02-20T14:11:18.639+0100    DEBUG    No secret config detected: trivy-secret.yaml
2023-02-20T14:11:18.639+0100    DEBUG    Image ID: sha256:18dbae858b8c595a7bc20dd0ed5412efd6cfac9ce97aec1a8dd40878b1245923
2023-02-20T14:11:18.639+0100    DEBUG    Diff IDs: [sha256:ae34ff7e9bd8c1cbec33ea1de76e15b6189d4475addc1e89a9498f6eef6d8764 sha256:222e93310b1193470069ad53234a8a2d67bc78bb45ed34831324d2bb0678e38a sha256:cd86a1853a4f3c7c398e99a87004b31e1ddd36e4e93ad72a8b4862b3d054d145]
2023-02-20T14:11:18.639+0100    DEBUG    Base Layers: [sha256:ae34ff7e9bd8c1cbec33ea1de76e15b6189d4475addc1e89a9498f6eef6d8764]
2023-02-20T14:11:18.640+0100    DEBUG    Missing image ID in cache: sha256:18dbae858b8c595a7bc20dd0ed5412efd6cfac9ce97aec1a8dd40878b1245923
2023-02-20T14:11:18.641+0100    DEBUG    No secrets found in container image config
2023-02-20T14:11:18.643+0100    DEBUG    OS is not detected.
2023-02-20T14:11:18.643+0100    DEBUG    Detected OS: unknown
2023-02-20T14:11:18.643+0100    INFO     Number of language-specific files: 1
2023-02-20T14:11:18.643+0100    INFO     Detecting gobinary vulnerabilities...
2023-02-20T14:11:18.643+0100    DEBUG    Detecting library vulnerabilities, type: gobinary, path: bin/memcached_exporter

bin/memcached_exporter (gobinary)
=================================
Total: 1 (UNKNOWN: 0, LOW: 1, MEDIUM: 0, HIGH: 0, CRITICAL: 0)

┌──────────────────┬────────────────┬──────────┬───────────────────┬───────────────┬─────────────────────────────────────────────────────────────┐
│     Library      │ Vulnerability  │ Severity │ Installed Version │ Fixed Version │                            Title                            │
├──────────────────┼────────────────┼──────────┼───────────────────┼───────────────┼─────────────────────────────────────────────────────────────┤
│ golang.org/x/net │ CVE-2022-41723 │ LOW      │ v0.4.0            │ 0.7.0         │ [http2/hpack: avoid quadratic complexity in hpack decoding] │
│                  │                │          │                   │               │ https://avd.aquasec.com/nvd/cve-2022-41723                  │
└──────────────────┴────────────────┴──────────┴───────────────────┴───────────────┴─────────────────────────────────────────────────────────────┘

Please update it to the latest version

release request

The latest release is at 2016,
do we have a plan to release new version of memcached_exporter?

"memcached_up" add memcached address variables

now “memcached_up” variables just has exporter serves address, when multiple exporters in one serves, it`s very hard to distinguish which one is i need. Would be nice, if can add memcached address value in “memcached_up” variables.
like redis_exporter
thx!

Multiple instance

Hi,
thank you for the exporter. Do you have any plans to support multiple instance on one server? Would be nice, if we don't have to start N exporters depend on how much instance we are running. Debian support multiple instance by default.

Add ability to allow or disable specific metrics

Would there be any interest in new configuration that allows the users to choose which metrics are sent by the exporter? I can submit a pull request.

In my use case we have thousands of pods running memcache and we have exceeded our quota for metrics so we want to restrict the metrics sent to the ones that are needed.

COPY memcached_exporter /bin/memcached_exporter

I use docker hub build this Dockerfile, show me an error:

Building in Docker Cloud's infrastructure...
Cloning into '.'...

KernelVersion: 4.4.0-91-generic
Arch: amd64
BuildTime: 2017-03-28T19:26:53.326478373+00:00
ApiVersion: 1.27
Version: 17.03.1-ee-2
MinAPIVersion: 1.12
GitCommit: ad495cb
Os: linux
GoVersion: go1.7.5
Starting build of index.docker.io/tianctrl/memcached_exporter:latest...
Step 1/5 : FROM quay.io/prometheus/busybox:latest

---> 61c7be62c779

Step 2/5 : MAINTAINER The Prometheus Authors [email protected]

---> Running in a2b64f7cc8d6

---> 3f0be8dcb947

Removing intermediate container a2b64f7cc8d6

Step 3/5 : COPY memcached_exporter /bin/memcached_exporter

lstat memcached_exporter: no such file or directory

Provide ARM64 binary

At Arm and Linaro we are working on getting Kolla-Kubernetes to deploy OpenStack on ARM64. But the deployment need to deploy memcached_exporter docker image, which the image building need haproxy_exporter binary for ARM64.

We may help with getting it built.

Failed to collect stats from memcached

Launched exporter with command

.\memcached_exporter.exe --memcached.address="192.168.4.3:11211"

Exporter returns

←[31mERRO←[0m[0012] Failed to collect stats from memcached: read tcp 192.168.4.213:30319->192.168.4.3:11211: i/o timeout
  ←[31msource←[0m="main.go:363"

Confirmed memcached running on server

telnet 192.168.4.3 11211
Trying 192.168.4.3...
Connected to server.domain.com.
Escape character is '^]'.
stats
STAT delete_misses 0
STAT rejected_conns 0
STAT connection_structures 5000
STAT reclaimed 4020063
STAT limit_maxbytes 67108864
STAT decr_hits 0
STAT curr_conns_on_port_11209 6
STAT curr_conns_on_port_11210 16
STAT curr_connections 24
STAT cas_misses 0
STAT bytes 3866242172
STAT get_misses 455
STAT bytes_read 77280398035
STAT get_hits 2824
STAT decr_misses 0
STAT bucket_conns 20
STAT cmd_flush 0
STAT uptime 1650605
STAT max_conns_on_port_11209 1000
STAT total_items 4523279
STAT incr_hits 0
STAT max_conns_on_port_11210 9000
STAT time 1553099096
STAT daemon_connections 4
STAT pointer_size 64
STAT version 2.0.1_linux_1_gb5e981f
STAT engine_maxbytes 4294967296
STAT evictions 279920
STAT total_connections 26
STAT curr_items 222167
STAT delete_hits 527
STAT cas_hits 0
STAT auth_errors 0
STAT threads 4
STAT pid 7544
STAT auth_cmds 16
STAT cas_badval 0
STAT cmd_set 4523279
STAT bucket_active_conns 1
STAT cmd_get 3279
STAT conn_yields 0
STAT listen_disabled_num 0
STAT bytes_written 85554892389
STAT libevent 2.0.11-stable
STAT accepting_conns 1
STAT incr_misses 0
END

conn_yields and listen_disabled_num

Hi!

I am wondering if it would be worth to add conn_yields and listen_disabled_num to the exporter. They seems to be very useful metrics that should be reported. In case the answer is yes I can help and send a patch to review :)

Luca

staticcheck build failure on v0.5.0

I'm trying to build the exporter inside my Dockerfile as a compile step.

Dockerfile looks like this:

FROM golang:1.10 as compile

WORKDIR /go/src/github.com/prometheus/memcached_exporter

RUN git clone -b v0.5.0 https://github.com/prometheus/memcached_exporter.git .

RUN make

The output of the make step is

>> checking code style
! gofmt -d $(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
GOOS= GOARCH= go get -u honnef.co/go/tools/cmd/staticcheck
>> running staticcheck
/go/bin/staticcheck -ignore "" ./...
main.go:519:26: error strings should not be capitalized (ST1005)
main.go:523:26: error strings should not be capitalized (ST1005)
Makefile.common:73: recipe for target 'staticcheck' failed
make: *** [staticcheck] Error 1
The command '/bin/sh -c make' returned a non-zero code: 2

I've also tried this with golang:1.11 and it fails the same way.

Is there something wrong in the way I've setup my build environment?

Cut new release to clear backlog of CVEs

Related to #112, but this is just a request to cut one quick release right away to clear a backlog of overdue CVEs (the last release was 10 months ago). The topic raised in #112 is related, but not the same; as it says, it would still be nice to systematically cut regular releases on roughly a monthly cadence.

tests are broken with latest memcached version

While debugging failures for #65 I noticed that they were due to a change in the memcached stats rather than the move from Go 1.12 to 1.13...

To confirm, I've modified the Circle CI configuration so it runs tests against v1.5.16 and latest. This fails for the latest memcached image (see https://circleci.com/gh/prometheus/memcached_exporter/264).

The test error message is main_test.go:142: want metrics to include "memcached_slab_mem_requested_bytes{slab=\"5\"} 194", have:.... It seems that mem_requested stats have moved from the slabs stats to the items stats:

*** stats.slabs.1.5.16  2019-09-13 13:57:35.313452365 +0200
--- stats.slabs.1.5.17  2019-09-13 13:58:21.661464012 +0200
*************** STAT 1:total_chunks 10922
*** 5,11 ****
  STAT 1:used_chunks 1
  STAT 1:free_chunks 10921
  STAT 1:free_chunks_end 0
- STAT 1:mem_requested 68
  STAT 1:get_hits 2
  STAT 1:cmd_set 3
  STAT 1:delete_hits 0
--- 5,10 ----
*************** STAT 5:total_chunks 4369
*** 21,27 ****
  STAT 5:used_chunks 1
  STAT 5:free_chunks 4368
  STAT 5:free_chunks_end 0
- STAT 5:mem_requested 194
  STAT 5:get_hits 0
  STAT 5:cmd_set 1
  STAT 5:delete_hits 0
--- 20,25 ----
*** stats.items.1.5.16	2019-09-13 13:57:53.279456885 +0200
--- stats.items.1.5.17	2019-09-13 13:58:14.033462095 +0200
*************** STAT items:1:number_warm 0
*** 4,10 ****
  STAT items:1:number_cold 1
  STAT items:1:age_hot 0
  STAT items:1:age_warm 0
! STAT items:1:age 188
  STAT items:1:evicted 0
  STAT items:1:evicted_nonzero 0
  STAT items:1:evicted_time 0
--- 4,11 ----
  STAT items:1:number_cold 1
  STAT items:1:age_hot 0
  STAT items:1:age_warm 0
! STAT items:1:age 7
! STAT items:1:mem_requested 68
  STAT items:1:evicted 0
  STAT items:1:evicted_nonzero 0
  STAT items:1:evicted_time 0
*************** STAT items:5:number_warm 0
*** 31,37 ****
  STAT items:5:number_cold 1
  STAT items:5:age_hot 0
  STAT items:5:age_warm 0
! STAT items:5:age 188
  STAT items:5:evicted 0
  STAT items:5:evicted_nonzero 0
  STAT items:5:evicted_time 0
--- 32,39 ----
  STAT items:5:number_cold 1
  STAT items:5:age_hot 0
  STAT items:5:age_warm 0
! STAT items:5:age 7
! STAT items:5:mem_requested 194
  STAT items:5:evicted 0
  STAT items:5:evicted_nonzero 0
  STAT items:5:evicted_time 0

There might other differences though...

any plans to support binary protocols?

I used docker-compose to run memcached's binary protocol and ascii.

memcached exporter does not seem to support binary protocols.
Are there plans to support binary protocols?

docker-compose file

$ cat docker-compose.yml
version: '3'
services:
  exporter1:
    image: prom/memcached-exporter
    command: -memcached.address memcache1:11211
    ports:
      - "9150:9150"
    links:
      - memcache1
  exporter2:
    image: prom/memcached-exporter
    command: -memcached.address memcache2:11211
    ports:
      - "9151:9150"
    links:
      - memcache2
  memcache1:
    image: memcached:1.5.3
    command: -m 128 -B ascii
    ports:
      - "11211:11211"
  memcache2:
    image: memcached:1.5.3
    command: -m 128 -B binary
    ports:
      - "11212:11211"

exporter result

ascii(http://127.0.0.1:9150/metrics)

# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 0
go_gc_duration_seconds{quantile="0.25"} 0
go_gc_duration_seconds{quantile="0.5"} 0
go_gc_duration_seconds{quantile="0.75"} 0
go_gc_duration_seconds{quantile="1"} 0
go_gc_duration_seconds_sum 0
go_gc_duration_seconds_count 0
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 8
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.9.2"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 899784
# HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
# TYPE go_memstats_alloc_bytes_total counter
go_memstats_alloc_bytes_total 899784
# HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.
# TYPE go_memstats_buck_hash_sys_bytes gauge
go_memstats_buck_hash_sys_bytes 1.443064e+06
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 266
# HELP go_memstats_gc_cpu_fraction The fraction of this program's available CPU time used by the GC since the program started.
# TYPE go_memstats_gc_cpu_fraction gauge
go_memstats_gc_cpu_fraction 0
# HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.
# TYPE go_memstats_gc_sys_bytes gauge
go_memstats_gc_sys_bytes 137216
# HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use.
# TYPE go_memstats_heap_alloc_bytes gauge
go_memstats_heap_alloc_bytes 899784
# HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.
# TYPE go_memstats_heap_idle_bytes gauge
go_memstats_heap_idle_bytes 57344
# HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.
# TYPE go_memstats_heap_inuse_bytes gauge
go_memstats_heap_inuse_bytes 1.712128e+06
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 6828
# HELP go_memstats_heap_released_bytes Number of heap bytes released to OS.
# TYPE go_memstats_heap_released_bytes gauge
go_memstats_heap_released_bytes 0
# HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system.
# TYPE go_memstats_heap_sys_bytes gauge
go_memstats_heap_sys_bytes 1.769472e+06
# HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection.
# TYPE go_memstats_last_gc_time_seconds gauge
go_memstats_last_gc_time_seconds 0
# HELP go_memstats_lookups_total Total number of pointer lookups.
# TYPE go_memstats_lookups_total counter
go_memstats_lookups_total 26
# HELP go_memstats_mallocs_total Total number of mallocs.
# TYPE go_memstats_mallocs_total counter
go_memstats_mallocs_total 7094
# HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures.
# TYPE go_memstats_mcache_inuse_bytes gauge
go_memstats_mcache_inuse_bytes 3472
# HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system.
# TYPE go_memstats_mcache_sys_bytes gauge
go_memstats_mcache_sys_bytes 16384
# HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures.
# TYPE go_memstats_mspan_inuse_bytes gauge
go_memstats_mspan_inuse_bytes 26296
# HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system.
# TYPE go_memstats_mspan_sys_bytes gauge
go_memstats_mspan_sys_bytes 32768
# HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place.
# TYPE go_memstats_next_gc_bytes gauge
go_memstats_next_gc_bytes 4.473924e+06
# HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations.
# TYPE go_memstats_other_sys_bytes gauge
go_memstats_other_sys_bytes 797696
# HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator.
# TYPE go_memstats_stack_inuse_bytes gauge
go_memstats_stack_inuse_bytes 327680
# HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator.
# TYPE go_memstats_stack_sys_bytes gauge
go_memstats_stack_sys_bytes 327680
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# TYPE go_memstats_sys_bytes gauge
go_memstats_sys_bytes 4.52428e+06
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
go_threads 5
# HELP http_request_duration_microseconds The HTTP request latencies in microseconds.
# TYPE http_request_duration_microseconds summary
http_request_duration_microseconds{handler="prometheus",quantile="0.5"} NaN
http_request_duration_microseconds{handler="prometheus",quantile="0.9"} NaN
http_request_duration_microseconds{handler="prometheus",quantile="0.99"} NaN
http_request_duration_microseconds_sum{handler="prometheus"} 0
http_request_duration_microseconds_count{handler="prometheus"} 0
# HELP http_request_size_bytes The HTTP request sizes in bytes.
# TYPE http_request_size_bytes summary
http_request_size_bytes{handler="prometheus",quantile="0.5"} NaN
http_request_size_bytes{handler="prometheus",quantile="0.9"} NaN
http_request_size_bytes{handler="prometheus",quantile="0.99"} NaN
http_request_size_bytes_sum{handler="prometheus"} 0
http_request_size_bytes_count{handler="prometheus"} 0
# HELP http_response_size_bytes The HTTP response sizes in bytes.
# TYPE http_response_size_bytes summary
http_response_size_bytes{handler="prometheus",quantile="0.5"} NaN
http_response_size_bytes{handler="prometheus",quantile="0.9"} NaN
http_response_size_bytes{handler="prometheus",quantile="0.99"} NaN
http_response_size_bytes_sum{handler="prometheus"} 0
http_response_size_bytes_count{handler="prometheus"} 0
# HELP memcached_commands_total Total number of all requests broken down by command (get, set, etc.) and status.
# TYPE memcached_commands_total counter
memcached_commands_total{command="cas",status="badval"} 0
memcached_commands_total{command="cas",status="hit"} 0
memcached_commands_total{command="cas",status="miss"} 0
memcached_commands_total{command="decr",status="hit"} 0
memcached_commands_total{command="decr",status="miss"} 0
memcached_commands_total{command="delete",status="hit"} 0
memcached_commands_total{command="delete",status="miss"} 0
memcached_commands_total{command="flush",status="hit"} 0
memcached_commands_total{command="get",status="hit"} 0
memcached_commands_total{command="get",status="miss"} 0
memcached_commands_total{command="incr",status="hit"} 0
memcached_commands_total{command="incr",status="miss"} 0
memcached_commands_total{command="set",status="hit"} 0
memcached_commands_total{command="touch",status="hit"} 0
memcached_commands_total{command="touch",status="miss"} 0
# HELP memcached_connections_total Total number of connections opened since the server started running.
# TYPE memcached_connections_total counter
memcached_connections_total 11
# HELP memcached_current_bytes Current number of bytes used to store items.
# TYPE memcached_current_bytes gauge
memcached_current_bytes 0
# HELP memcached_current_connections Current number of open connections.
# TYPE memcached_current_connections gauge
memcached_current_connections 10
# HELP memcached_current_items Current number of items stored by this instance.
# TYPE memcached_current_items gauge
memcached_current_items 0
# HELP memcached_items_evicted_total Total number of valid items removed from cache to free memory for new items.
# TYPE memcached_items_evicted_total counter
memcached_items_evicted_total 0
# HELP memcached_items_reclaimed_total Total number of times an entry was stored using memory from an expired entry.
# TYPE memcached_items_reclaimed_total counter
memcached_items_reclaimed_total 0
# HELP memcached_items_total Total number of items stored during the life of this instance.
# TYPE memcached_items_total counter
memcached_items_total 0
# HELP memcached_limit_bytes Number of bytes this server is allowed to use for storage.
# TYPE memcached_limit_bytes gauge
memcached_limit_bytes 1.34217728e+08
# HELP memcached_malloced_bytes Number of bytes of memory allocated to slab pages.
# TYPE memcached_malloced_bytes gauge
memcached_malloced_bytes 0
# HELP memcached_max_connections Maximum number of clients allowed.
# TYPE memcached_max_connections gauge
memcached_max_connections 1024
# HELP memcached_read_bytes_total Total number of bytes read by this server from network.
# TYPE memcached_read_bytes_total counter
memcached_read_bytes_total 7
# HELP memcached_up Could the memcached server be reached.
# TYPE memcached_up gauge
memcached_up 1
# HELP memcached_uptime_seconds Number of seconds since the server started.
# TYPE memcached_uptime_seconds counter
memcached_uptime_seconds 14
# HELP memcached_version The version of this memcached server.
# TYPE memcached_version gauge
memcached_version{version="1.5.3"} 1
# HELP memcached_written_bytes_total Total number of bytes sent by this server to network.
# TYPE memcached_written_bytes_total counter
memcached_written_bytes_total 0
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.03
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1.048576e+06
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 8
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 6.053888e+06
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.51745893953e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 1.2169216e+07

binary(http://127.0.0.1:9151/metrics)

# HELP go_gc_duration_seconds A summary of the GC invocation durations.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 0
go_gc_duration_seconds{quantile="0.25"} 0
go_gc_duration_seconds{quantile="0.5"} 0
go_gc_duration_seconds{quantile="0.75"} 0
go_gc_duration_seconds{quantile="1"} 0
go_gc_duration_seconds_sum 0
go_gc_duration_seconds_count 0
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 7
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.9.2"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 895640
# HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
# TYPE go_memstats_alloc_bytes_total counter
go_memstats_alloc_bytes_total 895640
# HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.
# TYPE go_memstats_buck_hash_sys_bytes gauge
go_memstats_buck_hash_sys_bytes 1.443088e+06
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 253
# HELP go_memstats_gc_cpu_fraction The fraction of this program's available CPU time used by the GC since the program started.
# TYPE go_memstats_gc_cpu_fraction gauge
go_memstats_gc_cpu_fraction 0
# HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.
# TYPE go_memstats_gc_sys_bytes gauge
go_memstats_gc_sys_bytes 137216
# HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use.
# TYPE go_memstats_heap_alloc_bytes gauge
go_memstats_heap_alloc_bytes 895640
# HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.
# TYPE go_memstats_heap_idle_bytes gauge
go_memstats_heap_idle_bytes 163840
# HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.
# TYPE go_memstats_heap_inuse_bytes gauge
go_memstats_heap_inuse_bytes 1.6384e+06
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 6741
# HELP go_memstats_heap_released_bytes Number of heap bytes released to OS.
# TYPE go_memstats_heap_released_bytes gauge
go_memstats_heap_released_bytes 0
# HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system.
# TYPE go_memstats_heap_sys_bytes gauge
go_memstats_heap_sys_bytes 1.80224e+06
# HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection.
# TYPE go_memstats_last_gc_time_seconds gauge
go_memstats_last_gc_time_seconds 0
# HELP go_memstats_lookups_total Total number of pointer lookups.
# TYPE go_memstats_lookups_total counter
go_memstats_lookups_total 26
# HELP go_memstats_mallocs_total Total number of mallocs.
# TYPE go_memstats_mallocs_total counter
go_memstats_mallocs_total 6994
# HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures.
# TYPE go_memstats_mcache_inuse_bytes gauge
go_memstats_mcache_inuse_bytes 3472
# HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system.
# TYPE go_memstats_mcache_sys_bytes gauge
go_memstats_mcache_sys_bytes 16384
# HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures.
# TYPE go_memstats_mspan_inuse_bytes gauge
go_memstats_mspan_inuse_bytes 25080
# HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system.
# TYPE go_memstats_mspan_sys_bytes gauge
go_memstats_mspan_sys_bytes 32768
# HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place.
# TYPE go_memstats_next_gc_bytes gauge
go_memstats_next_gc_bytes 4.473924e+06
# HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations.
# TYPE go_memstats_other_sys_bytes gauge
go_memstats_other_sys_bytes 797672
# HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator.
# TYPE go_memstats_stack_inuse_bytes gauge
go_memstats_stack_inuse_bytes 294912
# HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator.
# TYPE go_memstats_stack_sys_bytes gauge
go_memstats_stack_sys_bytes 294912
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# TYPE go_memstats_sys_bytes gauge
go_memstats_sys_bytes 4.52428e+06
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
go_threads 4
# HELP http_request_duration_microseconds The HTTP request latencies in microseconds.
# TYPE http_request_duration_microseconds summary
http_request_duration_microseconds{handler="prometheus",quantile="0.5"} NaN
http_request_duration_microseconds{handler="prometheus",quantile="0.9"} NaN
http_request_duration_microseconds{handler="prometheus",quantile="0.99"} NaN
http_request_duration_microseconds_sum{handler="prometheus"} 0
http_request_duration_microseconds_count{handler="prometheus"} 0
# HELP http_request_size_bytes The HTTP request sizes in bytes.
# TYPE http_request_size_bytes summary
http_request_size_bytes{handler="prometheus",quantile="0.5"} NaN
http_request_size_bytes{handler="prometheus",quantile="0.9"} NaN
http_request_size_bytes{handler="prometheus",quantile="0.99"} NaN
http_request_size_bytes_sum{handler="prometheus"} 0
http_request_size_bytes_count{handler="prometheus"} 0
# HELP http_response_size_bytes The HTTP response sizes in bytes.
# TYPE http_response_size_bytes summary
http_response_size_bytes{handler="prometheus",quantile="0.5"} NaN
http_response_size_bytes{handler="prometheus",quantile="0.9"} NaN
http_response_size_bytes{handler="prometheus",quantile="0.99"} NaN
http_response_size_bytes_sum{handler="prometheus"} 0
http_response_size_bytes_count{handler="prometheus"} 0
# HELP memcached_up Could the memcached server be reached.
# TYPE memcached_up gauge
memcached_up 0
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
process_cpu_seconds_total 0.04
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
process_max_fds 1.048576e+06
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
process_open_fds 8
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
process_resident_memory_bytes 6.94272e+06
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
process_start_time_seconds 1.51745893962e+09
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
process_virtual_memory_bytes 1.2169216e+07

Export "direct_reclaims"

There is a memcached bug where this error appears:

level=debug ts=2022-06-23T10:28:27.220696365Z caller=memcached_client.go:406 name=frontend-cache msg="failed to store item to memcached" key=1@b2ae91c4319dafc4 sizeBytes=86848 server=10.70.1.208:11211 err="memcache: unexpected response line from \"set\": \"SERVER_ERROR out of memory storing object\\r\\n\""

The above is logged from here.

Background (from related issue):

Memcached 1.5 and above uses a segmented LRU by default (blog post). Items can be evicted by a background routine if they’re expired, or directly during a mset operation if the cache memory is full. The latter operation is called a “direct reclaim”.

Query-frontend caches results with 7d TTL. Since the load test has run for less than 7d, presumably all evictions are caused by direct reclaims. Using the stat command on memcached shows:
0 reclaimed (Number of times an entry was stored using memory from an expired entry)
0 crawler_reclaimed (Total items freed by LRU Crawler)
983890 direct_reclaims (Times worker threads had to directly reclaim or evict items)

We would like the above “direct_reclaims” metric to be exported in Prometheus.

Support binding to specific interface

I would prefer not to bind the exporter to 0.0.0.0 global interface, is there a chance to add arbitrary available interfaces/ip addresses?

my use case: i usually bind utility services like exporters to private ip-s or vpn-delimited ip ranges.

Cleanup metric names and types

It looks like a number of metric names are copies of the raw memcached stats names. These don't follow naming best practices and many likely need some cleanup work.

Also, it seems like a number of metrics are being exposed as counters, when some of them are gauges.

Release 0.1.0 ?

@grobie What's your plan for this ? IIRC you wanted to do the slab support before that, but maybe can we cut a 0.1.0 and keep the slab metrics for the 0.2.0.

make error on rpi4

Hi there,

I got, on rpi4

$ gmake
>> checking code style
>> checking license header
>> running check for unused/missing packages in go.mod
GO111MODULE=on go mod tidy
>> running check for unused packages in vendor/
GO111MODULE=on go mod vendor
curl -s -L https://github.com/prometheus/promu/releases/download/v0.5.0/promu-0.5.0.freebsd-arm64.tar.gz | tar -xvzf - -C /tmp/tmp.RlawSuU0
tar: Error opening archive: Unrecognized archive format

It's because promu-0.5.0.freebsd-arm64.tar.gz does not exists, but promu-0.5.0.freebsd-armv7.tar.gz does, and it fits.

I propose this patch (work for me, but should be refined) :

--- Makefile.common.bak 2020-08-25 17:37:16.700726000 +0200
+++ Makefile.common     2020-08-25 17:44:25.175934000 +0200
@@ -66,7 +66,11 @@
        GOHOSTARM ?= $(shell GOARM= $(GO) env GOARM)
        GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH)v$(GOHOSTARM)
 else
-       GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH)
+ifeq (arm64, $(GOHOSTARCH))
+       GO_BUILD_PLATFORM ?= $(GOHOSTOS)-armv7
+else
+       GO_BUILD_PLATFORM ?= $(GOHOSTOS)-$(GOHOSTARCH)v7
+endif
 endif

 GOTEST := $(GO) test

"Failed to parse" errors

I'm getting multiple errors on every scrape:

ERRO[0496] Failed to parse touch_hits "": strconv.ParseFloat: parsing "": invalid syntax  source="main.go:479"
ERRO[0496] Failed to parse touch_misses "": strconv.ParseFloat: parsing "": invalid syntax  source="main.go:479"
ERRO[0496] Failed to parse touch_hits "": strconv.ParseFloat: parsing "": invalid syntax  source="main.go:479"
ERRO[0496] Failed to parse touch_hits "": strconv.ParseFloat: parsing "": invalid syntax  source="main.go:479"
ERRO[0496] Failed to parse touch_hits "": strconv.ParseFloat: parsing "": invalid syntax  source="main.go:479"
ERRO[0496] Failed to parse touch_hits "": strconv.ParseFloat: parsing "": invalid syntax  source="main.go:479"
ERRO[0496] Failed to parse touch_hits "": strconv.ParseFloat: parsing "": invalid syntax  source="main.go:479"
ERRO[0496] Failed to parse touch_hits "": strconv.ParseFloat: parsing "": invalid syntax  source="main.go:479"
ERRO[0496] Failed to parse touch_hits "": strconv.ParseFloat: parsing "": invalid syntax  source="main.go:479"
ERRO[0496] Failed to parse touch_hits "": strconv.ParseFloat: parsing "": invalid syntax  source="main.go:479"
ERRO[0496] Failed to parse touch_hits "": strconv.ParseFloat: parsing "": invalid syntax  source="main.go:479"
ERRO[0496] Failed to parse touch_hits "": strconv.ParseFloat: parsing "": invalid syntax  source="main.go:479"

The scrape itself is successful, but I end up with "NaN" values for all touch metrics. Any idea how resolve this?

Failed to collect stats from memcached: dial tcp 127.0.0.1:11211

My error: msg="Failed to collect stats from memcached: dial tcp 127.0.0.1:11211: connect: connection refused" source="main.go:517"

I run container like this:
docker run -d -p 9150:9150 prom/memcached-exporter --memcached.address 127.0.0.1:11211

My memcached listen localhost:11211

netstat -tunlp | grep memcached                                                                                                                                               
tcp        0      0 127.0.0.1:11211         0.0.0.0:*               LISTEN      8310/memcached

I can connect to via cli:
telnet 127.0.0.1 11211 root@www Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. stats STAT pid 8310 STAT uptime 626626
What am I doing wrong?

90% of stats are memcached_slab_*

Looking for ways to economize on total stats production, I found that on our project we are seeing around

11000 stats/interval total for 2 memcached clusters.
9600 stats/interval with the prefix memcached_slab

I don't even know how someone is supposed to interpret that telemetry. I certainly don't think users want to pay 90% of their stats budget for slab allocator data. I'd like a way to turn that off.

In a related ticket that was closed by the author, it was suggested to drop stats at the collector, but collector configs could be shared by any number of services running on the same box, and getting communal access to that configuration is a whole other layer of logistics to manage, possibly 2. With swarm or Kubernetes managing them you are asking for one person to drop all of the stats collection for several teams.

make error

make

checking code style
checking license header
running golangci-lint
GO111MODULE=on go list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
GO111MODULE=on /root/go/bin/golangci-lint run ./...
running check for unused/missing packages in go.mod
GO111MODULE=on go mod tidy
running check for unused packages in vendor/
GO111MODULE=on go mod vendor
building binaries
GO111MODULE=on /root/go/bin/promu build --prefix /root/software/memcached_exporter
memcached_exporter
running all tests
GO111MODULE=on go test -race -mod=vendor ./...
--- FAIL: TestAcceptance (0.12s)
panic: runtime error: slice bounds out of range [:3] with length 0 [recovered]
panic: runtime error: slice bounds out of range [:3] with length 0

goroutine 8 [running]:
testing.tRunner.func1.1(0xc1c2e0, 0xc000025820)
/root/go/src/testing/testing.go:988 +0x452
testing.tRunner.func1(0xc0000acea0)
/root/go/src/testing/testing.go:991 +0x600
panic(0xc1c2e0, 0xc000025820)
/root/go/src/runtime/panic.go:975 +0x3e3
github.com/prometheus/memcached_exporter.TestAcceptance(0xc0000acea0)
/root/software/memcached_exporter/main_test.go:172 +0x2495
testing.tRunner(0xc0000acea0, 0xc7e500)
/root/go/src/testing/testing.go:1039 +0x1ec
created by testing.(*T).Run
/root/go/src/testing/testing.go:1090 +0x701
FAIL github.com/prometheus/memcached_exporter 0.145s
FAIL
make: *** [common-test] Error 1

[Question] Use of grobie/gomemcache instead of bradfitz/gomemcache ?

This is just a simple question to understand the usage of a forked repo, rather than the original. Are there any specific differences that are required for this exporter to work? That would be good to understand in the documentation.

I ran the latest master branch using the bradfitz/gomemcache module and tests do fail -

$ perl -pi -e 's|github.com/grobie/gomemcache/memcache|github.com/bradfitz/gomemcache/memcache|' main.go
$ make
>> checking code style
>> running staticcheck
chmod +x /usr/local/google/home/erikwebb/go/bin/staticcheck
GO111MODULE=on go list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
go: finding github.com/bradfitz/gomemcache/memcache latest
go: finding github.com/bradfitz/gomemcache latest
GO111MODULE=on /usr/local/google/home/erikwebb/go/bin/staticcheck -ignore "" ./...
main.go:352:12: cannot initialize 2 variables with 1 values (compile)
main.go:352:12: cannot initialize 2 variables with 1 values (compile)
main.go:352:12: cannot initialize 2 variables with 1 values (compile)
Makefile.common:142: recipe for target 'common-staticcheck' failed
make: *** [common-staticcheck] Error 1

Release

This package as not been released this year yet. We should consider bumping go, the dependencies anc craft a release.

extstore statistics

When extstore is enabled, stats outputs some additional stats relating to it. They're in line with existing stats (storage used/limit, read/write/eviction counts, etc.) and adding them to the exporter is pretty simple, but they don't exist when extstore isn't enabled, so it requires some special handling to only export them when they actually exist, which I'm not quite sure on how to do.

Example of stats
STAT extstore_compact_lost 0
STAT extstore_compact_rescues 0
STAT extstore_compact_skipped 0
STAT extstore_page_allocs 0
STAT extstore_page_evictions 0
STAT extstore_page_reclaims 0
STAT extstore_pages_free 5119
STAT extstore_pages_used 1
STAT extstore_objects_evicted 0
STAT extstore_objects_read 0
STAT extstore_objects_written 0
STAT extstore_objects_used 0
STAT extstore_bytes_evicted 0
STAT extstore_bytes_written 0
STAT extstore_bytes_read 0
STAT extstore_bytes_used 0
STAT extstore_bytes_fragmented 67108864
STAT extstore_limit_maxbytes 343597383680

Support multiple memcache daemons

The original implementation supported multiple memcache servers. For my usage, running multiple memcached daemons per machine scales better than one and I was using that feature.

Late to the commit party, sorry....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.