transcodeninja / livepeer-exporter

A Prometheus exporter for Livepeer orchestrator metrics. Fetches and exposes orchestrator metrics from various Livepeer endpoints for Prometheus to scrape.
https://hub.docker.com/r/rickstaa/livepeer-exporter
MIT License
0 stars 0 forks source link

Replace stronk API calls with calls to TheGraph #54

Closed rickstaa closed 11 months ago

rickstaa commented 11 months ago

Is your feature request related to a problem? Please describe.

@stronk-dev brought https://api.thegraph.com/subgraphs/name/livepeer/arbitrum-one/graphql to my attention. This endpoint can fetch most of the information I currently fetch from https://stronk.rocks.

Rewards call example

{
  rewardEvents (where: {delegate: "0x9d61ae5875e89036fbf6059f3116d01a22ace3c8"}){
    id
    rewardTokens
    delegate {
      id
    }
  }
}

Describe the solution you'd like

I want to replace the https://stronk.rocks calls with https://api.thegraph.com/subgraphs/name/livepeer/arbitrum-one/graphql calls to ellivate the https://stronk.rocks service.

Describe alternatives you've considered

No response

Additional context

TODOs

stronk-dev commented 11 months ago

Don't forget the first param, IIRC the default range is 100 entries in the response. Caching the subgraph data is also recommended to ensure snappy response times for your API

{
  rewardEvents(
    where: {delegate: "0x9d61ae5875e89036fbf6059f3116d01a22ace3c8"}
    first: 1000
  ) {
    id
    rewardTokens
    delegate {
      id
    }
  }
}

Another query which might be interesting:

transcoder(id: "0x847791cbf03be716a7fe9dc8c9affe17bd49ae5e") {
            id
            activationRound
            deactivationRound
            active
            status
            lastRewardRound {
              id
              length
              startBlock
              endBlock
              mintableTokens
              volumeETH
              volumeUSD
              totalActiveStake
              totalSupply
              participationRate
              movedStake
              newStake
            }
            rewardCut
            feeShare
            totalStake
            totalVolumeETH
            totalVolumeUSD
            serviceURI
            delegators(first: 1000) {
              id
              bondedAmount
              startRound
            }
            delegator {
              id
              bondedAmount
              startRound
            }
          }
        }
rickstaa commented 11 months ago

Don't forget the first param, IIRC the default range is 100 entries in the response. Caching the subgraph data is also recommended to ensure snappy response times for your API

{
  rewardEvents(
    where: {delegate: "0x9d61ae5875e89036fbf6059f3116d01a22ace3c8"}
    first: 1000
  ) {
    id
    rewardTokens
    delegate {
      id
    }
  }
}

Another query which might be interesting:

transcoder(id: "0x847791cbf03be716a7fe9dc8c9affe17bd49ae5e") {
            id
            activationRound
            deactivationRound
            active
            status
            lastRewardRound {
              id
              length
              startBlock
              endBlock
              mintableTokens
              volumeETH
              volumeUSD
              totalActiveStake
              totalSupply
              participationRate
              movedStake
              newStake
            }
            rewardCut
            feeShare
            totalStake
            totalVolumeETH
            totalVolumeUSD
            serviceURI
            delegators(first: 1000) {
              id
              bondedAmount
              startRound
            }
            delegator {
              id
              bondedAmount
              startRound
            }
          }
        }

Ah, thanks for the warning and the extra query. I will start migrating to the graph when I find time in my schedule 🚀.

stayForward09 commented 11 months ago

Hi, team. Is there any graphql query to get Daily Usage of Livepeer? Thanks.

rickstaa commented 11 months ago

Hi @stayForward09! If you're looking for daily usage data through an API, you can grab it from https://explorer.livepeer.org/api/usage. For Prometheus metrics, there's a feature request open at https://github.com/rickstaa/livepeer-exporter/issues/55. If you're after the GraphQL query on https://api.thegraph.com/subgraphs/name/livepeer/arbitrum-one, the data you seek should be under the Protocol field, but it seems missing. I'd recommend popping your question into the livepeer discord for more tailored assistance.

stayForward09 commented 11 months ago

@rickstaa Brilliant! Thanks for your kind help.

rickstaa commented 11 months ago

@rickstaa Brilliant! Thanks for your kind help.

No problem. I also just found the LivePeer subgraph on GitHub. I think you might request the feature there if you still need it 👍.

stayForward09 commented 11 months ago

Thanks so much.

On Wed, Nov 29, 2023 at 2:25 AM Rick Staa @.***> wrote:

@rickstaa https://github.com/rickstaa Brilliant! Thanks for your kind help.

No problem. I also just found the LivePeer subgraph on GitHub https://github.com/livepeer/subgraph/issues. I think you might request the feature there if you still need it 👍.

— Reply to this email directly, view it on GitHub https://github.com/rickstaa/livepeer-exporter/issues/54#issuecomment-1831292771, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7YDXXFV22YYHLOZ266DIFDYG3INVAVCNFSM6AAAAAA7SYJT72VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZRGI4TENZXGE . You are receiving this because you were mentioned.Message ID: @.***>

stronk-dev commented 11 months ago

Since work is off-chain, usage of the protocol cannot be measured. It would require all Orchestrators to publish their transcode stats (maybe on streamr?). You can get a rough estimate based on winning tickets redeemed, but since each O has their own price, luck, etc it's tough to translate that to minutes. https://explorer.livepeer.org/api/usage should be fairly accurate since LP Inc is the only major broadcaster on the network. They describe their method here: https://forum.livepeer.org/t/livepeer-explorer-minutes-estimation-methodology/2140

rickstaa commented 11 months ago

Since work is off-chain, usage of the protocol cannot be measured. It would require all Orchestrators to publish their transcode stats (maybe on streamr?). You can get a rough estimate based on winning tickets redeemed, but since each O has their own price, luck, etc it's tough to translate that to minutes. https://explorer.livepeer.org/api/usage should be fairly accurate since LP Inc is the only major broadcaster on the network. They describe their method here: https://forum.livepeer.org/t/livepeer-explorer-minutes-estimation-methodology/2140

@stronk-dev, thanks for jumping in on this topic! That makes sense. Thanks for the detailed explanation 👍🏻.

rickstaa commented 11 months ago

The orch_tickets_exporter was migrated in #67.

rickstaa commented 11 months ago

The orch_rewards_exporter was migrated in #69.

rickstaa commented 11 months ago

@stronk-dev now that https://github.com/transcodeninja/livepeer-exporter/pull/72 has been merged, this project no longer depends on your API.

rickstaa commented 11 months ago

Fixed in https://github.com/transcodeninja/livepeer-exporter/releases/tag/v2.2.0.