...would be my answer if the question you're asking is "Is this spell balanced".
I homebrew a LOT of spells, and I have yet to have one of them rejected by my DM. The way I always start is to find an existing spell that functions similarly to what my target spell will do. In your case, that target is a new Detection spell. Fortunately for you, there are a variety of spells we can examine, and use as a template.
Template #1: Detect Magic
There are three 1st level 'Detect' spells. All three have a range of 'self (30 foot sphere)', a duration of '10 minutes (concentration)', a casting time of 1 action, and contain this line:
The spell can penetrate most barriers, but it is blocked by 1 foot of
stone, 1 inch of common metal, a thin sheet of lead, or 3 feet of wood
Next, we tweak. You want your spell to reveal things about your target. This is a similar function to how Detect Magic works:
you can use your action to see a faint aura around any visible
creature or object in the area that bears magic, and you learn its
school of magic
Based on that, I think it's entirely reasonable for your spell to allow you to use an action to decipher one resistance, immunity, or vulnerability in a visible creature within range. This should be per round as well, because if you have 4 magic items in range, Detect Magic would take a round a piece to determine their schools of magic.
Template #2: Identify
Your target spell is also similar to Identify, which reveals all aspects of an object at once, and it would also make sense to use this spell as a template. However, Identify has a range of touch, casting time of 1 minute, and has a material component that costs 100gp. To me, this seems less desirable than using the first template.
You could totally combine the effect of Identify's 'reveal all the things' functionality, and the casting time/range/no expensive material component of the Detection spells....but now you're definitely talking about a 2nd level spell. If you combine the effects of two first level spells, the only way to keep the spell balanced is to make it at least one level higher. Also, I'd suggest giving this spell the ritual tag. This lets you leverage a longer casting time to save spell slots if you need to.
Comparison to the Ranger ability:
This spell is still not nearly as powerful. I've emphasized the key reasons why from the Monster Slayer Ranger's Hunter's Sense ability description:
At 3rd level, you gain the ability to peer at a creature and magically
discern how best to hurt it. As an action, choose one creature you can
see within 60 feet of you. You immediately learn whether the creature
has any damage immunities, resistances, or vulnerabilities and what
The Ranger ability has twice the range, and learns all about the target at once. This is slightly better than what I suggest in the Pro-level Homebrewing section above. That version of the spell would need to be 2nd level, which would require the caster to be the same level as the Ranger in order to access the spell. This is why I think either template version makes sense as a 1st level spell - it's just not nearly as good as the Ranger ability.
I'd say that a balanced homebrew spell that does what you want would look like:
Detect Resistance / Vulnerability
- Casting Time: 1 Action
- Duration: Concentration, up to 10 minutes
- Range: 30 feet
You target any creature you can see within range, and dissect it with your mind's eye. When casting this spell, and for every round thereafter while you hold concentration, you can use an action to learn one of this creature's resistances, vulnerabilities, or immunities. The caster is aware when there is nothing left to learn about the creature.
The spell can penetrate most barriers, but it is blocked by 1 foot of stone, 1 inch of common metal, a thin sheet of lead, or 3 feet of wood or dirt.
At higher levels: When you cast this spell using a spell slot of 2nd level or higher, you learn one additional trait per round for each slot level above 1st.